Azure地图图层相互叠加

问题描述 投票:2回答:1

我的天蓝色地图有问题。

发生的事情是我有两层。具有圆形的层和具有多边形的层。

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

当我在圆形图层之后添加多边形图层时,会发生此问题。就像多边形层被绘制在圆形层的顶部。在这种情况下,单击圆圈时可以防止弹出窗口出现。

这是我添加多边形图层的方式:

  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
        }
      }));
    });
}
}

任何人都知道如何解决此问题?

azure-maps
1个回答
0
投票

我在您提供的代码中看不到多边形层。也就是说,将图层添加到地图时,默认情况下,添加顺序为z-index。最后添加的是最重要的。也就是说,在使用map.layers.add函数添加图层时,您可以添加第二个参数,其中可以是另一个图层或图层ID。指定此图层后,您要添加的图层将插入到该第二个指定图层的下方。这是文档:https://docs.microsoft.com/en-us/javascript/api/azure-maps-control/atlas.layermanager?view=azure-maps-typescript-latest#add-layer---layer----string---layer-

这里是一个简短的例子:

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

map.layers.add(new atlas.layers.PolygonLayer(datasource, 'myPolygons'), 'myBubbles');
© www.soinside.com 2019 - 2024. All rights reserved.