其他分享
首页 > 其他分享> > 调用高德地图Api

调用高德地图Api

作者:互联网

Xml文件
<com.amap.api.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapView"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</com.amap.api.maps.MapView>

Java代码
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (mapLayout == null) {
mapLayout = inflater.inflate(R.layout.map_fragment, null);
mapView = (MapView) mapLayout.findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
if (aMap == null) {
aMap = mapView.getMap();
aMap.setMapType(AMap.MAP_TYPE_SATELLITE);// 设置卫星地图模式,aMap是地图控制器对象。
}
}else {
if (mapLayout.getParent() != null) {
((ViewGroup) mapLayout.getParent()).removeView(mapLayout);
}
}
RealTimePositionVelocityCalculator currentPositionVelocityCalculator =
mPositionVelocityCalculator;
if (currentPositionVelocityCalculator != null) {
currentPositionVelocityCalculator.setMapFragment(this);
}

return mapLayout;
}

标签:调用,mapLayout,id,mapView,Api,aMap,android,null,高德
来源: https://www.cnblogs.com/blogger-Li/p/11616857.html