通过类Overlay并从该类调用onTap方法,我可以在我的地图上显示drawables。我想要做的就是当用户点击地图(第一次点击)时显示一个drawable,而不是通过点击在不同的地方再次显示drawable。这可能吗?
答案 0 :(得分:0)
override you onTap() method of Overlay
@Override
protected boolean onTap(int index) {
Drawable srcdrawable = getApplicationContext().getResources().getDrawable(R.drawable.pin_blue);
CustomItemizedOverlay srcitemizedOverlay = new CustomItemizedOverlay(srcdrawable, getApplicationContext());
forloop(setoflocations){
GeoPoint srcpoint = new GeoPoint((int)( Double.parseDouble(lat) * 1E6),(int)( //latitude and longitude of user tapped location...
Double.parseDouble(lng)* 1E6));
OverlayItem srcoverlayitem = new OverlayItem(srcpoint, "Hello!", "This is your Location.");
if(srcitemizedOverlay!=null && mapController!=null){
srcitemizedOverlay.addOverlay(overlayitem);
mapController.animateTo(point);
animatePoint = point;
}
}
mapView.getOverlays().clear();
mapView.getOverlays().add(srcitemizedOverlay);
// pop up a alert dialog here and ask user for confirmation
}