1
我在我的應用程序中有一個谷歌地圖與不同的標記。當我點擊一個標記(onTap())時,會出現一個新的細節窗口,並提供關於特定位置的一些信息。我的問題是,當我點擊後,整個地圖重繪。我可以看到它,因爲每次打開infowindow並單擊後退按鈕時,標記的陰影變暗。此外,它總是放大到我當前的位置( - >觸發整個onResume()方法)。谷歌地圖重新點擊後退按鈕
我該如何避免每次重繪地圖?
疊加的物品類別:
@Override
public boolean onTap(int index) {
OverlayItem item = mOverlays.get(index);
Item item = map.get(item);
Intent intent = new Intent();
intent.setClass(mContext, SomeExampleClass.class);
mContext.startActivity(intent);
return true;
}
地圖類:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.map);
mapView = (MapView) findViewById(R.id.mainmap);
mapView.invalidate();
mapView.setBuiltInZoomControls(true);
dbZugriff = new DatabaseAccess(this);
mylocationoverlay = new MyLocationOverlay(this, mapView);
mc = mapView.getController();
}
@Override
protected void onResume() {
super.onResume();
mylocationoverlay.enableMyLocation();
mapView.getOverlays().add(mylocationoverlay);
mylocationoverlay.runOnFirstFix(new Runnable(){
@Override
public void run() {
GeoPoint myLocation = mylocationoverlay.getMyLocation();
mc.animateTo(myLocation);
mc.setZoom(16);
mapView.postInvalidate();
}
});
SharedPreferences prefs = getSharedPreferences("prefs",Context.MODE_PRIVATE);
SpecialitiesSelection specialitiesSelection = SpecialitiesSelection.loadFromPreferences(prefs, "");
Cursor resultat = dbZugriff.createCursor(specialitiesSelection);
mapOverlays = mapView.getOverlays();
List<Item> list = new ArrayList<Item>();
if (resultat.moveToFirst()){
do{
Item daten = Item.createFromCursor(resultat);
list.add(daten);
}
while(resultat.moveToNext());
}
Drawable drawable = this.getResources().getDrawable(R.drawable.ic_launcher);
itemizedoverlay = new ItemOverlay(drawable,this,list);
mapOverlays.add(itemizedoverlay);
}