问题1:使用js 8c的客户端,添加了一个动态切片底图,一个vectorLayer,一个graphicLayer。给map添加了一个selectGraphic的控件,且设置graphicLayer的hitDetection为true,但运行时无法选中图层要素。graphicLayer在map的最上层。
问题2:需求是想要同时选中graphicLayer和vectorlayer的对象,声明一个selectFeature,并且把vectorLayer放在map最上层,可以选中,放在graphicLayer下面就无法选中,渲染方式是canvas。我查看了,graphicLayer也是依托canvas,怎么还会遮盖vectorLayer的选择事件呢?
代码如下:
var textlayer, graphicLayer;
var SelectFeature;
var map,layer, vectorLayer,url;
function init(){
url = currUser.mapUrl;
map = new SuperMap.Map("map",{controls:[
new SuperMap.Control.Navigation({
dragPanOptions: {
enableKinetic: true
}
})
]});
layer= new SuperMap.Layer.TiledDynamicRESTLayer("World", url, null);
layer.events.on({"layerInitialized":addLayer});
graphicLayer = new SuperMap.Layer.Graphics("Can Select Graphic Layer",null,{hitDetection: true}); //可以选择,开启事件
textlayer = new SuperMap.Layer.Vector("Label",{strategies: [trainStrategy],renderers: ["Canvas"]});
selectGraphic = new SuperMap.Control.SelectGraphic(graphicLayer, {
onSelect: function(result,event){alert('1111');}
});
map.addControl(selectGraphic);
selectGraphic.activate();
}
function addLayer(){
map.addLayers([layer,textlayer,graphicLayer]);
map.maxScale = 1/100000;
//map.addControl(overviewmap);
map.addControl(scaleline);
$('.smControlScaleLineBottom').remove();
//显示地图范围
map.setCenter(new SuperMap.LonLat(12009634.286396, 4258716.5813769),4);
}