Azure地图层正在相互叠加



我使用的是azure地图。

现在的情况是我有两层。具有圆形的层和具有多边形的层。

我有一个功能,当我点击一个特定的圆圈时,会出现一个弹出窗口。

当我在圆形层之后添加多边形层时,就会出现这个问题。

这就像多边形层被绘制在圆形层的顶部。在其中,它可以防止点击圆圈时出现弹出窗口。

以下是我添加多边形层的方法:

showFetchedResultOnMap(facilities) {
const self = this;
if (facilities && facilities.length > 0) {
self.cleanRestrictionLayer();
//Create a data source and add it to the map.
self.datasource = new atlas.source.DataSource();
self.map.sources.add(self.datasource);
//Add a data set to the data source. 
self.CleanMap();
//Create a data source and add it to the map.
var datasource = new atlas.source.DataSource();
self.map.sources.add(datasource);
self.map.imageSprite.add(self.chosenCategory, 'assets/svg/' + self.chosenCategory + '.svg')
.then(function () {
facilities.forEach(cat => {
datasource.add(new atlas.data.Feature(new atlas.data.Point([cat.longitude, cat.latitude])));
});
//Add a layer for rendering point data as symbols.
self.map.layers.add(new atlas.layer.SymbolLayer(datasource, self.chosenCategory, {
iconOptions: {
//Pass in the id of the custom icon that was loaded into the map resources.
image: self.chosenCategory,
//Optionally scale the size of the icon.
size: 0.1
}
}));
});
}
}

有人知道我该怎么解决这个问题吗??

我在您提供的代码中没有看到多边形层。也就是说,当您将层添加到地图时,默认情况下添加它们的顺序是z索引。最后添加的一个位于顶部。也就是说,当使用map.layers.add函数添加图层时,您可以在其中添加第二个参数,该参数可以是另一个图层或图层id。当指定该参数时,您要添加的图层将插入第二个指定图层下方。这是关于这个的文档:https://learn.microsoft.com/en-us/javascript/api/azure-maps-control/atlas.layermanager?view=azure-地图typescript最新#添加图层----字符串----图层-

下面是一个简短的例子:

map.layers.add(new atlas.layers.BubbleLayer(datasource, 'myBubbles'));
map.layers.add(new atlas.layers.PolygonLayer(datasource, 'myPolygons'), 'myBubbles');

最新更新