TiledDynamicRESTLayer设裁剪面clipRegion问题

0 投票

使用产品:iclient8c 操作系统:win7 x64

TiledDynamicRESTLayer设置剪面clipRegion属性无效


//绘制多边形获得多边形Geometry
handlerPolygon.drawEvt.addEventListener(function(result){
                tooltip.setVisible(false);
                handlerPolygon.polygon.show = false;
                handlerPolygon.polyline.show = false;
                for(var a = 0;a<result.object.positions.length;a++){
                    var position = result.object.positions[a];
                    var longitude = position.y;
                    var latitude = position.z;
                    var queryPoint = {
                        x: longitude,
                        y: latitude
                    };
                    points.push(new SuperMap.Geometry.Point(queryPoint.x,queryPoint.y));
                }
                var linearRings = new SuperMap.Geometry.LinearRing(points);
                var region = new SuperMap.Geometry.Polygon([linearRings]);
                fanwei = region;
})
//加载图层
function GetMap() {
                    map = new SuperMap.Map("map", {
                        controls: [
                            new SuperMap.Control.Navigation(),
                            new SuperMap.Control.Zoom()]
                    });
                    layerMain = new SuperMap.Layer.TiledDynamicRESTLayer("yx", url,
                        {clipRegion:fanwei,clipRegionEnabled:true})
                    layerMain.events.on({ "layerInitialized": addLayer });
                    vector = new SuperMap.Layer.Vector("vector");
                    addData();
                }

                function addLayer() {
                    map.addLayers([layerMain, vector]);
                    map.setCenter(new SuperMap.LonLat(mapSettingObj.birdEye.x,mapSettingObj.birdEye.y),4);
                }

11月 29, 2019 分类:  267次浏览 | 用户: XiaoMing王 才疏学浅 (12 分)

1个回答

0 投票

你好,我这边测试是没有问题的。我比较怀疑是你构造的面有点问题,导致分析失败,建议在检查下代码

我这边写的demo已经私发给你了,具体的可以参考我的demo改动。

11月 29, 2019 用户: 阳俊林 名扬四海 (3,347 分)

因为我加载地图是用webgl的方法,所以我用的绘制多边形的方法也是webgl的,我取到绘制以后的点坐标在代码中转换成二维面了,结果裁剪不起作用。但是我在上面绘制多边形就可以,说明构造面没问题吧。


 function addLayer() {
                    map.addLayers([layerMain]);
                    map.setCenter(new SuperMap.LonLat(mapSettingObj.birdEye.x,mapSettingObj.birdEye.y),4);
                            var layerMaincut= new SuperMap.Layer.TiledDynamicRESTLayer("yxcut", url,
                                {clipRegion:fanwei},{maxResolution: "auto"});
                            layerMaincut.events.on({ "layerInitialized": function (){
                                    map.removeLayer(layerMain);
                                    map.addLayers([layerMaincut,vector]);
                                    var polygonVector = new SuperMap.Feature.Vector(fanwei);
                                    vector.addFeatures([polygonVector]);
                                }});
                }

非常感谢,我那个号登不上去了,你可以私信我这个号demo嘛。
var url;
                var layerMain;
                var map;
                var drawPolygon,vecotrLayer;
                vecotrLayer = new SuperMap.Layer.Vector("polygonLayer");
                drawPolygon = new SuperMap.Control.DrawFeature(vecotrLayer,SuperMap.Handler.Polygon);
                    map = new SuperMap.Map("map", {
                        controls: [
                            new SuperMap.Control.Navigation(),
                            new SuperMap.Control.Zoom(),
                            drawPolygon]
                    });
                    layerMain = new SuperMap.Layer.TiledDynamicRESTLayer("yx", url,
                        null,{maxResolution: "auto"})
                    layerMain.events.on({ "layerInitialized": addLayer });
                    vecotrLayer.style = {
                    fillColor: "blue",
                    fillOpacity: 1,
                    hoverFillColor: "white",
                    hoverFillOpacity: 0.8,
                    strokeColor: "#ee9900",
                    strokeOpacity: 1,
                    strokeWidth: 1,
                    strokeLinecap: "round",
                    strokeDashstyle: "solid",
                    hoverStrokeColor: "red",
                    hoverStrokeOpacity: 1,
                    hoverStrokeWidth: 0.2,
                    pointRadius: 6,
                    hoverPointRadius: 1,
                    hoverPointUnit: "%",
                    pointerEvents: "visiblePainted",
                    cursor: "inherit",
                    fontColor: "#000000",
                    labelAlign: "cm",
                    labelOutlineColor: "white",
                    labelOutlineWidth: 3
                };
                function deactiveAll() {
                    drawPolygon.deactivate();
                }

                function addLayer() {
                    map.addLayers([layerMain]);
                    map.setCenter(new SuperMap.LonLat(mapSettingObj.birdEye.x,mapSettingObj.birdEye.y),4);
                    deactiveAll();
                    drawPolygon.activate();
                    drawPolygon.events.on({"featureadded":function (e) {
                        console.log(e.feature.geometry);
                            var layerMaincut= new SuperMap.Layer.TiledDynamicRESTLayer("yxcut", url,
                                {clipRegion:e.feature.geometry},{maxResolution: "auto"});
                            layerMaincut.events.on({ "layerInitialized": function (){
                                    map.removeLayer(layerMain);
                                    map.addLayers([layerMaincut]);
                                }});
                        }})
                }

我换了绘制面方式依旧不行,代码执行没报错,地图闪烁了一下,应该是remove和addlayer,可是没有剪切效果。

我看到例子上都是4326和3857丹丹底图,平面坐标系底图支持裁剪吗?
...