2017-10-27 6 views

答えて

2

ここでは、サイズに基づいてマーカーを作成するための方法である:

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を追加する必要があります。

TouchOverlyがある
mapView.getOverlays().add(new TouchOverlay()); 

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 
} 
関連する問題