《点击选择地图定位》
操作与功能:点击地图定位控件,选择地图上的任意一点,获取到相应点的数据信息。
代码说明:首先创建一个图层,声明查询数据的类型和需要显示的图层,给一个注册事件
,当调用 active 方法激活时调用方法drawPointCompleted_selectPoint
//选择救助点
function alarmPointSelection() {
resultlistHide(); //隐藏搜索结果列表
alarmMessageHide();//隐藏底部报警信息
//移除报警图层所有点
alarmMarkerLayer.clearMarkers();
//移除地图所有点要素
vectorLayer_WG.removeAllFeatures();
drawPoint_signPoint.activate();//开启选择案发点标记选择
//移除地图所以弹窗
map.removeAllPopup();
}
$(function(){
//选择事故地点
drawPoint_signPoint = new SuperMap.Control.DrawFeature(//绘制要素类。
vectorLayer_WG,//显示的图层
SuperMap.Handler.Point//查询类型,点查询
);
//注册事件
drawPoint_signPoint.events.on({
"featureadded": drawPointCompleted_selectPoint }//完成选择点回调方法
);
});
接收服务器传递的数据,调用deactivate注销方法,声明变量获取传递数据的几何对象,声明一个数组,设置查询参数。
{SuperMap.REST.FilterParameter} 空间关系分析中的源数据集查询参数。仅 ids、attributeFilter 和 fields 字段有效。
//选择事故地点完成事件
function drawPointCompleted_selectPoint(drawGeometryArgs) {
drawPoint_signPoint.deactivate();//停止选择案发点标记
var geometry = drawGeometryArgs.feature.geometry;//获取几何对象
console.log(geometry);
geometryCase = geometry;
var queryParams = [];//查询参数
//空间关系分析中的参考数据集查询参数
//push() 方法可向数组的末尾添加一个或多个元素,并返回新的长度。
queryParams.push(new SuperMap.REST.FilterParameter({
name: "P02机场_point_1@FoShanChanCheng" }));
queryParams.push(new SuperMap.REST.FilterParameter({
name: "P01政府机构_point_1@FoShanChanCheng" }));
queryParams.push(new