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

How to show HereMaps inside an android Linear Layout

有没有办法在线性布局中显示 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);

还有test/check onResume() onPause()。

在这种情况下使用 MapView 而不是 MapFragment。该文档已链接 here for starter and here 以获得高级版。