GIS画圆范围查询信息

在开发GIS地理信息的相关项目中,既然是有关于GIS的项目,那么首先第一步就是需要地图信息,然后就是通过代码,在项目里面将地图加载出来,地图加载出来以后,就可以通过代码进行功能的开发的
接下来给大家讲解一下GIS地理信息系统里面最常用的一个功能的开发,那就是查询一个范围的信息
也就是圆查询,简单来说:就是通过鼠标点击确定一个中心点,然后按着鼠标拉开半径,以圆点和半径确认一个圆,只查询这个圆里面的信息:比如查询这个圆范围里面的某一些医疗机构什么的等等。
这圆查询的讲解我通过我之前做过的一个GIS慢性病地理信息管理系统来进行代码说明
首先,要先引用由iServer的插件
在这里插入图片描述
然后我们得确定一个圆,也就是在地图上画出来一个圆:代码如下(例如我们要查询该地图上所有的医院的信息,那么就查询P15医疗服务_point_1这个数据集的信息)
//画圆
//画圆
function drawGeometry1() {
lineLayer.removeAllFeatures();
closeInfoWin();
//先清除上次的显示结果
clearStatus();
drawPolygon1.activate();
}
function drawCompleted3(drawGeometryArgs) {
drawRectangle.deactivate();
drawPolygon1.deactivate();
drawPolygon2.deactivate();
var feature = new SuperMap.Feature.Vector();
feature.geometry = drawGeometryArgs.feature.geometry,
feature.style = style;
vectorLayer.addFeatures(feature);
var queryParam, queryByGeometryParameters, queryService;
queryParam = new SuperMap.REST.FilterParameter({ name: “P15医疗服务_point_1@Mxbgl” });
queryByGeometryParameters = new SuperMap.REST.QueryByGeometryParameters({
queryParams: [queryParam],
geometry: drawGeometryArgs.feature.geometry,
spatialQueryMode: SuperMap.REST.SpatialQueryMode.INTERSECT
});
queryService = new SuperMap.REST.QueryByGeometryService(url, {
eventListeners: {
“processCompleted”: processCompletedyuan,
“processFailed”: processFailed
}
});
queryService.processAsync(queryByGeometryParameters);
}
function processCompletedyuan(queryEventArgs) {
drawPolygon1.deactivate();
drawPolygon2.deactivate();
drawRectangle.deactivate();
var i, j, result = queryEventArgs.result;
if (result && result.recordsets) {
for (i = 0, recordsets = result.recordsets, len = recordsets.length; i < len; i++) {
if (recordsets[i].features) {
for (j = 0; j < recordsets[i].features.length; j++) {
var feature = recordsets[i].features[j];
var point = feature.geometry;
if (point.CLASS_NAME == SuperMap.Geometry.Point.prototype.CLASS_NAME) {
var size = new SuperMap.Size(33, 33),
offset = new SuperMap.Pixel(-(size.w / 2), -size.h),
icon = new SuperMap.Icon("/theme/images/cluster3.png", size, offset);
marker = new SuperMap.Marker(new SuperMap.LonLat(point.x, point.y), icon);
marker.name = feature.attributes.NAME;
marker.laction = feature.attributes.ADDRESS;
marker.GISID = feature.attributes.SmID;
marker.Dianhua = feature.attributes.TELEPHONE;

                        } else {
                            feature.style = style;
                            vectorLayer.addFeatures(feature);
                        }
                        markerLayer.addMarker(marker);
                        marker.events.on({
                            "click": mouseClickHandleryuan,//触发click事件会调用弹窗方法
                            "touchstart": mouseClickHandleryuan,//假如要在移动端的浏览器也实现点
                        });
                    }
                }
            }
        }
    }
    function mouseClickHandleryuan(event) {
        closeInfoWin();
        var XCoordinate = event.object.lonlat.lon;
        var YCoordinate = event.object.lonlat.lat;
        var name = event.object.name;
        var laction = event.object.laction;
        var Dianhua = event.object.Dianhua;
        var contentHTML = "
医疗点
名称: " + name + "
所在地址: " + laction + "
联系电话:" + Dianhua + "
"; var size = new SuperMap.Size(21, 25), offset = new SuperMap.Pixel(-(size.w / 2), -size.h), icon = new SuperMap.Icon("/theme/images/cluster3.png", size, offset); framedCloud = new SuperMap.Popup.FramedCloud( "popwin", new SuperMap.LonLat(XCoordinate, YCoordinate), null, contentHTML, icon, true, null, true ); infowinonMessage = framedCloud; map.addPopup(framedCloud); map.panTo(new SuperMap.LonLat(XCoordinate, YCoordinate)); }

效果如下;画出来一个圆,确定查询的范围
GIS画圆范围查询信息_第1张图片

你可能感兴趣的:(GIS画圆范围查询信息)