Получить FeatureId цели во всплывающем окне на векторном слое в листовке

#leaflet

#листовка

Вопрос:

Приведенный ниже код работает нормально, я получаю много интересных данных в getFeatureId. Как мне получить доступ к этому во всплывающем окне?

 var map = L.map('map').setView([53.505, -7.09], 7);

L.tileLayer('https://{s}.etc.etc/{z}/{x}/{y}.png', {
  attribution: 'osm..'
}).addTo(map);

var VectorTileOptions = {
  rendererFactory: L.canvas.tile,
  attribution: '',
  interactive: true,
  getFeatureId:function(feat){
    return feat.properties.routes
  }
};

var TilesPbfLayer = L.vectorGrid.protobuf(tileurl, VectorTileOptions).addTo(map);

var popup = L.popup();
map.on('popupopen', function(e) {
  popup.setContent("how do i get the feature Id ? ")
});
TilesPbfLayer.bindPopup(popup)
  

Ответ №1:

Я могу получить событие щелчка на слое плитки, и у него есть слой с моими материалами в

 TilesPbfLayer.on('click', function(e) {
    if (e.layer)
        popup.setContent(e.layer.properties.routes)
})