答案 0 :(得分:3)
以下是根据尺寸创建标记的方法:
public Bitmap resizeMapIcons(String iconName,int width, int height){
Bitmap imageBitmap = BitmapFactory.decodeResource(getResources(),getResources().getIdentifier(iconName, "drawable", getPackageName()));
Bitmap resizedBitmap = Bitmap.createScaledBitmap(imageBitmap, width, height, false);
return resizedBitmap;
}
然后,您必须通过调用
将TouchOverly
添加到地图中
mapView.getOverlays().add(new TouchOverlay());
TouchOverly
的位置:
private class TouchOverlay extends com.google.android.maps.Overlay {
int lastZoomLevel = -1;
@Override
public boolean onTouchEvent(MotionEvent event, MapView mapview) {
if (event.getAction() == 1) {
lastZoomLevel = mapView.getZoomLevel();
if (mapView.getZoomLevel() != lastZoomLevel) {
onZoom(mapView.getZoomLevel());
lastZoomLevel = mapView.getZoomLevel();
}
}
return false;
}
}
最后在onZoom
中的地图上刷新标记:
private void onZoom(int level){
// resizeMapIcons
// clear markers
// add new markers
}
答案 1 :(得分:0)
如果标记是位图图像,我们可以使用
更改其宽度和高度Bitmap.createScaledBitmap(bitmapDp,width,hight,false); 我们需要从onCameraMove()回调中调用它。
for (int k = 0; k < markers.size(); k++) {
resizedBitmap(bitmapArrayList.get(k), 250, 250);
markers.get(k).setIcon(BitmapDescriptorFactory.fromBitmap(resizedBitmap));
}
public Bitmap resizedBitmap(Bitmap bitmapDp, int width, int hight) {
resizedBitmap = Bitmap.createScaledBitmap(bitmapDp, width, hight, false);
return resizedBitmap;
}