use of com.amap.api.maps.model.Marker in project YourEyes by SevenLJY.
the class MapActivity method updatePosition.
/**
* updatePosition():更新地图位置
* 在更新位置加上marker
* */
private void updatePosition(LatLng location) {
LatLng pos = location;
//创建一个设置经纬度的CameraUpdate
CameraUpdate cuLoc = CameraUpdateFactory.changeLatLng(pos);
//更新地图显示区域
aMap.moveCamera(cuLoc);
//清除地图所有覆盖物
aMap.clear();
//创建一个MarkerOptions对象并使用自定义图标
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(pos);
markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.smallplaceholder));
markerOptions.draggable(true);
//添加marker
Marker marker = aMap.addMarker(markerOptions);
}
Aggregations