关于移动端地图显示设置标记点,要求点击标记显示图片,查看了SampleCode里面的OverlayDemo里面示例,实际操作发现进入地图设计标记点第一次点击能够打开,第二次点击没反应
添加标记的方法
drawableBlue = getResources().getDrawable(R.mipmap.pop_picture);
defaultItemizedOverlay = new DefaultItemizedOverlay(drawableBlue);
pointCenter = mapView.getCenter();
// geoPoints.add(new Point2D(pointCenter.getX(),pointCenter.getY()));
System.out.println("地图中心的坐标点是"+ pointCenter.getX()+";"+ pointCenter.getY());
OverlayItem overlayItem = new OverlayItem(pointCenter, "", "");
defaultItemizedOverlay.addItem(overlayItem);
defaultItemizedOverlay.setOnFocusChangeListener(new SelectedOverlay());
mapView.getOverlays().add(defaultItemizedOverlay);
mapView.invalidate();
/**
* Overlay焦点获取事件
*/
class SelectedOverlay implements ItemizedOverlay.OnFocusChangeListener {
@Override
public void onFocusChanged(ItemizedOverlay overlay, OverlayItem item) {
Toast.makeText(getApplicationContext(), "图片已经被点击", Toast.LENGTH_SHORT).show();
}
}