SuperMapGIS 区域定位

关键技术:SuperMap GIS
作者:李嘉乐
给每一个区域都设置了它们的中心坐标,通过自己写positioning方法根据x值来确定地位到的位置。
如图:在这里插入图片描述
代码如下:

 <li><a><i class="fa fa-map-marker"></i> 区域定位<span class="fa arrow"></span></a><ul class="nav nav-second-level"><li style="color:#db0a2f;font-weight:600">所选地区:<span class="dizhi">增城区</span> <span onclick="clean()" class="clean">清除定位</span></li><li class="panel-body" style="margin-left:-20px;"><div id="x" style="display:none"></div><div id="y" style="display:none"></div><div class="dingWei"><a onclick="positioning(1)">荔城街道</a><a onclick="positioning(2)">朱荔街道</a><a onclick="positioning(3)">朱村街道</a><a onclick="positioning(4)">新塘街道</a><a onclick="positioning(5)">沙浦街道</a><a onclick="positioning(6)">派潭街道</a></div></li></ul></li>function positioning(x) {if (x == 1) {$("#x").text("113.7136555");$("#y").text("23.164994");$(".dizhi").text("荔城街道")} else if (x == 2) {$("#x").text("113.708026216129");$("#y").text("23.3073192386678");$(".dizhi").text("朱荔街道")} else if (x == 3) {$("#x").text("113.67449256307");$("#y").text("23.404634");$(".dizhi").text("朱村街道")} else if (x == 4) {$("#x").text("113.7807705");$("#y").text("23.5331743939412");$(".dizhi").text("新塘街道")} else if (x == 5) {$("#x").text("113.848521311222");$("#y").text("23.453133084205");$(".dizhi").text("沙浦街道")} else if (x == 6) {$("#x").text("113.890901311222");$("#y").text("23.4004297508717");$(".dizhi").text("派潭街道")}QuYu.removeAllFeatures();//清除上次定位的图层var getFeatureParam, getFeatureBySQLService, getFeatureBySQLParams;getFeatureParam = new SuperMap.REST.FilterParameter({name: "区县界_region_1@ZengChengregion1",///图层名称attributeFilter: "ID = " + x});getFeatureBySQLParams = new SuperMap.REST.GetFeaturesBySQLParameters({queryParameter: getFeatureParam,//["ZengChengregion:区县界_region_1"]:数据源名称:数据集名称  并不是图层名称datasetNames: ["ZengChengregion:区县界_region_1"]});getFeatureBySQLService = new SuperMap.REST.GetFeaturesBySQLService(url2, {eventListeners: { "processCompleted": AreaDW, "processFailed": processFailed }});getFeatureBySQLService.processAsync(getFeatureBySQLParams);}//到指定的数据集,筛选到定位的数据
function AreaDW(getFeaturesEventArgs) {var i, len, features, feature, result = getFeaturesEventArgs.result;if (result && result.features) {features = result.featuresfor (i = 0, len = features.length; i < len; i++) {feature = features[i];feature.style = style1;QuYu.addFeatures(feature);//添加定位图层var x = document.getElementById("x").innerHTML;var y = document.getElementById("y").innerHTML;map.setCenter(new SuperMap.LonLat(x, y), 1);}}} //跳转到定位位置,并添加区域图层
function clean() {//先清除上次的显示结果QuYu.refresh();QuYu.removeAllFeatures();$(".dizhi").text("增城区")map.setCenter(new SuperMap.LonLat(113.796098771673, 23.2557633015387), 2);}//清除定位区域图层


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部