/** * 构造函数 * * @param mapView * @param dynView */ public QueryResultPopup(MapView mapView, DynamicView dynView) { mMapView = mapView; mMapControl = mapView.getMapControl(); mDynView = dynView; mInflater = LayoutInflater.from(mMapControl.getContext()); mTrackingLayer = mMapView.getMapControl().getMap().getTrackingLayer(); loadView(); setContentView(mContentView); setWidth(MyApplication.dp2px(350)); setHeight(MyApplication.dp2px(530)); mResultList.setAdapter(new QueryResultAdapter()); this.setOutsideTouchable(true); }
private void initView() { // 避免软键盘遮挡 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); // 初始化MapControl m_MapView = (MapView) findViewById(R.id.mapview); mMapControl = m_MapView.getMapControl(); // 初始化放大缩小按钮 btnZoomin = (Button) findViewById(R.id.zoomin); btnZoomout = (Button) findViewById(R.id.zoomout); btnZoomin.setOnClickListener(new zoominBtnlistener()); btnZoomout.setOnClickListener(new zoomoutBtnlistener()); btnFullScreen = (Button) findViewById(R.id.fullscreen); btnFullScreen.setOnClickListener(new fullScreenBtnListener()); btnMultiMedia = (Button) findViewById(R.id.multi_media); btnPlot = (Button) findViewById(R.id.plot); btnSendMessage = (Button) findViewById(R.id.send_message); btnConsultMessage = (Button) findViewById(R.id.consult_message); btnMessageSwitch = (Button) findViewById(R.id.message_switch); btnLocate = (Button) findViewById(R.id.locate); btnPositionUpload = (Button) findViewById(R.id.position_upload); btnTextMessage = (Button) findViewById(R.id.text_message); btnDelete = (Button) findViewById(R.id.delete); btnDelete.setOnClickListener(this); btnNewMessage = (TextView) findViewById(R.id.new_message); btnClear = (Button) findViewById(R.id.clear); btnClear.setOnClickListener(this); btnMultiMedia.setOnClickListener(this); btnPlot.setOnClickListener(this); btnSendMessage.setOnClickListener(this); btnConsultMessage.setOnClickListener(this); btnMessageSwitch.setOnClickListener(this); btnLocate.setOnClickListener(this); btnPositionUpload.setOnClickListener(this); btnTextMessage.setOnClickListener(this); // 文本消息初始化 m_popupTextMessage = new TextMessagePopup(btnTextMessage.getRootView(), getApplicationContext(), this); }
/** 清空查询结果 */ public void clear() { mDynView.clear(); mMapView.removeAllCallOut(); mResultData.clear(); loadView(); setContentView(mContentView); setWidth(MyApplication.dp2px(350)); setHeight(MyApplication.dp2px(530)); mResultList.setAdapter(new QueryResultAdapter()); this.setOutsideTouchable(true); dismiss(); }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.consult_message: { mMapControl.submit(); mMapControl.setAction(Action.SELECT); mMapControl.getMap().refresh(); if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) { m_popupMultiMedia.dismiss(); } if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) { m_PlotTypePopup.dismiss(); } m_nMessageCount = 0; btnNewMessage.setVisibility(4); showMessageList(v); } break; case R.id.message_switch: { if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) { m_popupMultiMedia.dismiss(); } if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) { m_PlotTypePopup.dismiss(); } mMessageQueueOn = !mMessageQueueOn; if (!mMessageQueueOn) { btnMessageSwitch.setBackgroundResource(R.drawable.btn_message_switch_noselect); m_MessageQueue.suspend(); } else { btnMessageSwitch.setBackgroundResource(R.drawable.btn_message_switch_focused); m_MessageQueue.resume(); // 先去下载一次多媒体数据 if (m_popupMultiMedia == null) { // 多媒体列表初始化 m_popupMultiMedia = new MultiMediaPopup(btnMultiMedia.getRootView(), getApplicationContext(), this); // 设置多媒体工作空间 m_popupMultiMedia.setWorkspace(mapShow.getWorkspace(), mapShow.getBounds()); } } } break; case R.id.locate: { if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) { m_popupMultiMedia.dismiss(); } if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) { m_PlotTypePopup.dismiss(); } m_StartPoint = m_TencentLocation.getGPSPoint(); if ((m_StartPoint.getX() == 0) || (m_StartPoint.getY() == 0)) { MyApplication.getInstance().showInfo("现在无法定位,请稍后再试!"); break; } // 导航纠偏 m_StartPoint = m_Navigation.encryptGPS(m_StartPoint.getX(), m_StartPoint.getY()); Point2D pt = mapShow.getPoint(m_StartPoint); if (pt == null) { MyApplication.getInstance().showInfo("现在无法定位,请稍后再试!"); break; } drawCircleOnDyn(pt, 0, m_TencentLocation.getAccuracy()); mapShow.panTo(pt); m_MapView.refresh(); } break; case R.id.multi_media: { mMapControl.submit(); mMapControl.setAction(Action.SELECT); mMapControl.getMap().refresh(); if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) { m_PlotTypePopup.dismiss(); } showMultiMediaPopup(v); break; } case R.id.plot: { if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) { m_popupMultiMedia.dismiss(); } mMapControl.submit(); mMapControl.setAction(Action.SELECT); mMapControl.getMap().refresh(); if (m_PlotTypePopup == null) { m_PlotTypePopup = new PlotTypePopup(mMapControl, btnPlot.getRootView(), this); } if (m_PlotTypePopup.isShowing()) { m_PlotTypePopup.dismiss(); mMapControl.setAction(Action.SELECT); } else { m_PlotTypePopup.show(v); } break; } case R.id.text_message: { mMapControl.submit(); mMapControl.setAction(Action.SELECT); mMapControl.getMap().refresh(); if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) { m_popupMultiMedia.dismiss(); } if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) { m_PlotTypePopup.dismiss(); } if (!mMessageQueueOn) { MyApplication.getInstance().showInfo("请先打开消息开关!"); break; } if (m_popupTextMessage == null) { m_popupTextMessage = new TextMessagePopup(btnTextMessage.getRootView(), getApplicationContext(), this); } if (m_popupTextMessage.isShowing()) { m_popupTextMessage.dismiss(); } else { m_popupTextMessage.setFocusable(true); m_popupTextMessage.show(); } } break; case R.id.send_message: { mMapControl.submit(); mMapControl.setAction(Action.SELECT); mMapControl.getMap().refresh(); if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) { m_popupMultiMedia.dismiss(); } if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) { m_PlotTypePopup.dismiss(); } if (!mMessageQueueOn) { MyApplication.getInstance().showInfo("请先打开消息开关!"); break; } sendPlot(); } break; case R.id.position_upload: { if (m_popupMultiMedia != null && m_popupMultiMedia.isShowing()) { m_popupMultiMedia.dismiss(); } if (m_PlotTypePopup != null && m_PlotTypePopup.isShowing()) { m_PlotTypePopup.dismiss(); } if (!mMessageQueueOn) { MyApplication.getInstance().showInfo("请先打开消息开关!"); break; } m_StartPoint = m_TencentLocation.getGPSPoint(); if ((m_StartPoint.getX() == 0) || (m_StartPoint.getY() == 0)) { MyApplication.getInstance().showInfo("现在无法定位,请稍后再试!"); break; } // 导航纠偏 m_StartPoint = m_Navigation.encryptGPS(m_StartPoint.getX(), m_StartPoint.getY()); String json = m_StartPoint.toJson(); String msg = "{content_type=0}" + json; boolean bOk = m_MessageQueue.sendMessageByType(msg, 0); if (bOk) { MyApplication.getInstance().showInfo("发送成功"); } else { MyApplication.getInstance().showInfo("发送失败,请重新发送!"); } } break; case R.id.delete: { if (m_layerSelected == null || m_IDSelected == -1) { break; } DatasetVector dataset = (DatasetVector) m_layerSelected.getDataset(); if (dataset != null && dataset.getName().equalsIgnoreCase("CAD")) { QueryParameter parameter = new QueryParameter(); parameter.setAttributeFilter("SmID=" + m_IDSelected); parameter.setCursorType(CursorType.DYNAMIC); Recordset recordset = dataset.query(parameter); recordset.moveFirst(); if (!recordset.isEmpty()) { String strPlotID = (String) recordset.getFieldValue("PlotID"); recordset.delete(); recordset.update(); String msg = "{content_type=5}"; msg += "{delete:feildName=PlotID,feildValue="; msg += strPlotID; msg += "}"; m_MessageQueue.sendMessageByRoutingKey(msg, "plot"); } recordset.close(); recordset.dispose(); } mMapControl.getMap().refresh(); mMapControl.setAction(Action.SELECT); m_IDSelected = -1; btnDelete.setVisibility(4); break; } case R.id.clear: { // 清空屏幕 clearScreen(); break; } default: { // mMapControl.getMap().refresh(); } } }