可能是因为所添加的Graphics图层存在问题,以下是可能的解决方案:
const graphicsLayer = new GraphicsLayer();
map.add(graphicsLayer);
var point = {
type: "point",
longitude: -118.409,
latitude: 33.943
};
var simpleMarkerSymbol = {
type: "simple-marker",
color: [226, 119, 40],
outline: {
color: [255, 255, 255],
width: 1
}
};
var pointGraphic = new Graphic({
geometry: point,
symbol: simpleMarkerSymbol
});
graphicsLayer.add(pointGraphic);
var graphicsLayer = new GraphicsLayer({
id: "graphicsLayer",
title: "Graphics Layer"
});
view.on("layerview-create", function(event){
if(someLayer.id === event.layer.id){
graphicsLayer.visible = true;
}
});
如果以上解决方案均未能解决问题,可以尝试添加以下代码以输出更多有关Graphics图层的信息:
graphicsLayer.on("layerview-create", function(event){
console.log(event);
});
以上方法中的代码示例仅供参考,并根据实际情况进行适当修改。