android 高德amap开发二(地图操作)

源代码例程:https://github.com/JiYangLin/ANDROID_PRJ_MODULE/tree/master/AMapPrj

 

首先需要获取控制器

在mapView初始化后可以获取控制器:

//初始化地图控制器对象 

AMap aMap = null;

if (aMap == null)  aMap = mMapView.getMap(); 

 

 

​​​​​​​设置标记点

LatLng latLng = new LatLng(39.906901,116.397972);
final Marker marker = aMap.addMarker(new MarkerOptions().position(latLng).title("北京").snippet("DefaultMarker"));

 

​​​​​​​标记点窗口的显示和隐藏

======实现地图点击和标记点点击接口

implements  AMap.OnMapClickListener, AMap.OnMarkerClickListener

 

private Marker curShowWindowMarker;
public boolean onMarkerClick(Marker marker) {
    curShowWindowMarker = marker;
    marker.showInfoWindow();
    return true;
}
public void onMapClick(LatLng latLng) {
    if(curShowWindowMarker!=null){
        curShowWindowMarker.hideInfoWindow();
    }
}

 

======设置监听

aMap.setOnMapClickListener(this);
aMap.setOnMarkerClickListener(this);

 

​​​​​​​设置标记点图标

aMap.addMarker(new MarkerOptions().***.icon(BitmapDescriptorFactory.fromResource(R.drawable.xx)));

 

​​​​​​​设置地图缩放大小

aMap.moveCamera(CameraUpdateFactory.zoomTo(5));

你可能感兴趣的:(Andriod)