Syline6.5学习心得-web-多边形查询

1.多边形查询:在地图中绘制某一范围后,对某一图层进行空间查询并高亮显示查询的要素。

2.主要使用的方法:

  • IFeauterLayer.ExecuteSpatialQuery();此方法对图层进行空间查询,缺点:大面积查询的时候会很慢,
  • IFeature65.Tint 属性设置要素的表面颜色

3.绘制函数的代码见前面的章节,下面是绘制后查询的主要代码:

function QueryByPolygon() {
    Draw.onDrawCompleted = onDrawCompleted;
    ClearBuffer();
    Draw.Polygon();
    
}
function onDrawCompleted(geo) {
    var sSuccess = "返回地物成功";
    if (geo == undefined || geo == null) {
        sSuccess = "返回地物失败";
        alert("绘制完成," + sSuccess);
    }
    else {
        //var area=geo.Area;
        //alert("绘制完成,面积为:" + area+" 平方米");
        //获取查询的图层
        var selectLayer = $('selectLayer');
        var slectedIndex = selectLayer.selectedIndex;
        var selLyrName = selectLayer.options[slectedIndex].text;
        var selLayer = ProjectTree.playersInfo[selLyrName];


        //ExecuteSpatialQuery( pIGeometry,IntersectionType)
        //IntersectionType=0:none;=1:intersect;=2:within
        var features = selLayer.ExecuteSpatialQuery(geo, 1);
        lastQueryFeatures = features;
        var containerRestult = document.getElementById("result");
        showReslts(features, containerRestult);

    }
    function showReslts(features,container) {
        if (features == null) return;
        var fcolor = NewColor(255, 0, 0, 100);
        var restStr = "<table>";
        for (var i = 0; i < features.Count; i++) {
            restStr += "<tr>";
            var feature = features.Item(i);
            feature.Tint = fcolor;
            for (var j = 0; j < feature.FeatureAttributes.Count; j++) {
                var featureAttribute = feature.FeatureAttributes.Item(j);
                restStr += "<td>" + featureAttribute.Name + "*" + featureAttribute.Value + "</td>";
            }
            restStr += "</tr>";
        }
        restStr += "</table>";
        if (container != null) {
            container.innerHTML = restStr;
        }
    }
   
   
    
}
function NewColor(r, g, b, a) {
    var sgworld = document.getElementById('sgworld');
    return sgworld.Creator.CreateColor(r, g, b, a);
}
var lastQueryFeatures = null;
function ClearBuffer() {
    Draw.Clear();
    if (lastQueryFeatures!=null) {
        for (var i = 0; i < lastQueryFeatures.Count; i++) {
            var feature = lastQueryFeatures.Item(i);
            feature.Tint = NewColor(0, 0, 0, 0);
        }
    }
}
4.效果展示




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值