问题
Is there a way to get a Map or MapView
without placing a MapFragmet
inside a Layout
?
<com.here.android.mpa.mapping.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/here_map"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
I already tried to place a MapView directly in my layout but there is no method to initialize or request a Map from it.
回答1:
You can have a com.here.android.mpa.mapping.MapView in your layout without the use of a fragment.
Simply call new com.here.android.mpa.mapping.Map()
and call com.here.android.mpa.mapping.MapView#setMap( map )
to attach the map to the map view.
Note you can only attach each map to a single map view. Also, make sure to call Mapview#onPause()
and MapView#onResume()
or the underlying textureview will not work correctly!
References: https://developer.here.com/mobile-sdks/documentation/android-hybrid-plus/topics_api_nlp_hybrid_plus/com-here-android-mpa-mapping-mapview.html#topic-apiref__setmap-map
来源:https://stackoverflow.com/questions/35506270/here-map-mapview-without-using-mapfragment