如何在Android线性布局中显示HereMaps

时间:2017-09-17 03:02:33

标签: android-layout android-linearlayout here-api

有没有在线性布局中显示HereMaps? 这是我的布局文件,我想在firstMap(LinearLayout)中显示地图。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="com.apploft.tabs.MyTabFragment">
<RelativeLayout
    android:id="@+id/confirmed"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout
        android:id="@+id/firstMap"
        android:layout_width="match_parent"
        android:layout_height="130dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="10dp"
        android:background="@color/cardview_shadow_start_color"
        android:orientation="horizontal">
        <!-- Map Fragment embedded with the map object -->
    </LinearLayout>
</FrameLayout>

在LinearLayout中添加maoview然后调用

<com.here.android.mpa.mapping.MapView
             android:id="@+id/mapview"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:visibility="visible"/>
片段中的

MapView mapColView = (MapView) colTabView.findViewById(R.id.mapview);
        map = new com.here.android.mpa.mapping.Map();
        map.setCenter(new GeoCoordinate(51.509865, -0.118092, 0.0), com.here.android.mpa.mapping.Map.Animation.NONE);
        // Set the zoom level to the average between min and max
        map.setZoomLevel((map.getMaxZoomLevel() + map.getMinZoomLevel()) / 2);
        mapColView.setMap(map);

同时测试/检查onResume()onPause()。

1 个答案:

答案 0 :(得分:2)

在这种情况下,使用MapView而不是MapFragment。文档链接here用于首发,here用于高级。