SpatialServer/Leaflet.MapboxVectorTile

Bind popup to feature

Closed this issue · 2 comments

How can I add a popup to a feature containing feature name and id?

fxi commented

Something like this in your config object should work:

onClick : function( e ){
    var feature = e.feature,
        coord = e.latlng;
    if( typeof feature !== undefined ){
      var prop = feature.properties;
      var popup = L.popup({ closeOnClick : true }) 
        .setLatLng( coord )
        .setContent( prop.name )
        .openOn( feature.map );
    }
  } 

I've used proposed solution in my project and can confirm - it works. @rishabhjain30 could you close issue?