Leaflet / Leaflet.VectorGrid

Display gridded vector data (sliced GeoJSON or protobuf vector tiles) in Leaflet 1.0.0
606 stars 194 forks source link

Add onEachFeature #131

Open tomchadwin opened 6 years ago

tomchadwin commented 6 years ago

Updated from #68, with deduplicating for labels added to example.

pkozul commented 4 years ago

Hi Tom,

I've used some of the code from this PR. Good work! I only needed to make one small change - provide the zoom level parameter when calling map.unproject().

    vtGeometryToLatLng: function(geometry, vtLayer, tileCoords) {
        return this._map.unproject(this.vtGeometryToPoint(geometry, vtLayer, tileCoords), tileCoords.z);
    }

When zooming in / out, sometimes the map's current zoom level and the requested tile zoom level are not the same, and so I was noticing some of my tiles were empty (i.e. the lats / longs were being calculated incorrectly and were therefore not being dsisplayed within the visible bounds of the map). I found it was due to the above code. Without supplying the optional zoom parameter, it defaults to using the map's current zoom level, rather than using the zoom level of the tile itself (since the zoom level could be different momentarily, while the user is zooming in / out).

Might be worth including this change in the PR?

Thanks!

zakjan commented 3 years ago

I'm wondering what's the status of this PR, and if it can be merged and released?