0
votes

I have a leaflet map which loads customer mapbox tilelayers. These tile layers have different properties and what I want is to be able to load a pop up when clicking on a specific tile. Is this possible?

I was able to get this to work using a straight GeoJSON but the files got too large for this to be economical and would cause browsers to crash. I have also tired to use geojson-vt but cannot get this to work.

If anyone has any other ideas as well apart from using Tiles I would love to hear them.

Our website these layers and maps are on is huntingspots.co.nz.

Thanks for you time.

Parriehunter

1
Could you make your question a bit explicit? Are you trying to show pop-ups for each feature of your mapbox layers that you add to the map? You could do that using a regular getjson function but can't using tileLayer from Mapbox? I am not sure of what you want to do but my first question is why are you using TileLayer rather than mapbox Feature Layer if you plan to have some onEachFeature behavior (mapbox.com/mapbox.js/api/v2.4.0/l-mapbox-featurelayer). Thank you for making your question a bit more precise.Philippe V.
Yes I am trying to show pop-ups for each feature.parriehunter
I then using mapbox created tile layers of the data and was able to add this to selectable layer on the map using leaflet. code L.tileLayer('mapbox').addTo(tracksLayer); codeparriehunter
Doing this has made the map a lot more responsive but unable to get a pop up of any of the data. If you have any recommendations on other ways to do this I am more than welcome to looking at them. you can see the live map at [link]huntingspots.co.nz[link]parriehunter

1 Answers

2
votes

You might be interested in Leaflet.utfgrid plugin.

It enables you to encode data into special tiles (so that you get the benefit of loading information only for what is on screen), that you can use to make up your popup when user clicks on the map.

The plugin demo shows information on "mouseover", but you should be able to change it for "click" without trouble.

Of course you have to create your UTF Grid tiles before hand, exactly like for your raster tiles.