首页 / 浏览问题 / 移动GIS / 问题详情
iclinet标注点击弹出对话框只能弹出一次
5EXP 2017年06月20日

 如图所示:点击起点和终点只能弹出分别弹出一次popupwindow。代码如下:

  private void initData() {
        DefaultItemizedOverlay overlay = new DefaultItemizedOverlay(mDrawableGreen);
        DefaultItemizedOverlay overlay2 = new DefaultItemizedOverlay(mDrawableRed);
        addLineOverLayer();
        mapView.setUseDoubleTapEvent(false);
        geoPoints.add(new Point2D(115.35721875156217,28.8643282757360495));//模拟三个坐标点画线
        geoPoints.add(new Point2D(115.35596090310354,28.86278948264622));
        geoPoints.add(new Point2D(115.35853250439675,28.860571942400618));
/**添加标注(起点和终点处添加表标记)*/
        OverlayItem itemBegin = new OverlayItem(new Point2D(115.35721875156217,28.8643282757360495), "起点","起点");
        OverlayItem itemEnd = new OverlayItem(new Point2D(115.35853250439675,28.860571942400618), "终点","终点");
        overlay.addItem(itemBegin);
        overlay2.addItem(itemEnd);
        overlay.setOnFocusChangeListener(new SelectedOverlay());
        overlay2.setOnFocusChangeListener(new ItemizedOverlay.OnFocusChangeListener() {
            @Override
            public void onFocusChanged(ItemizedOverlay itemizedOverlay, OverlayItem overlayItem) {
                mPopup.showPopupWindow();
            }
        });
        mapView.getOverlays().add(overlay);
        mapView.getOverlays().add(overlay2);
        mapView.invalidate();
        setOverlayData(lineOverlays.get(lineOverlays.size() - 1));
    }
    /**
     * Overlay焦点获取事件
     */
    class SelectedOverlay implements ItemizedOverlay.OnFocusChangeListener {

        @Override
        public void onFocusChanged(ItemizedOverlay overlay, OverlayItem item) {
//			// 地图中心漫游至当前OverlayItem
//			mapView.getController().animateTo(item.getPoint());
//			Toast.makeText(mapView.getContext().getApplicationContext(), item.getTitle(), Toast.LENGTH_SHORT).show();
            // 弹出气泡展示消息

           mPopup.showPopupWindow();
//            popWindow.showPopupWindow(mapView, item);

        }

    }

问题关闭原因: 已解决
...