Leaflet / Leaflet.VectorGrid

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

L.VectorGrid.Slicer loading slowly #190

Closed Tojens closed 5 years ago

Tojens commented 5 years ago

Hi

I've used this plugin to slice a GeoJSON into tiles with some success, since it now displays, albeit pretty slowly. The GeoJSON in question is retrieved from a PostGIS database using php to construct the GeoJSON. I'm a bit stumped as to what I should be doing to have it render faster, since I'm not sure if it's slow because I'm getting the data from PostGIS or if I have to adjust the geojson-vt options.

The geojson takes up about 44mb as a local file.

I've tried to set up a plunkr showing the relevant bits of code (but nothing in the preview): https://next.plnkr.co/edit/Thfbc5rEufTgk0t9?preview

Hope someone can point me in the right direction.

Tojens commented 5 years ago

Figured it out on my own and I feel pretty stupid. I was displaying the wrong feature, that being the one I hadn't sliced.

tomchadwin commented 5 years ago

I know you've solved your issue, but I just wondered about your "using php to construct the GeoJSON". Do you mean that you are querying PostGIS and using PHP to build JSON by concatenating strings as you loop through the returned recordset? If so, you could improve performance greatly by making the conversion to GeoJSON in your PostGIS query with eg ST_AsGeoJSON().

Tojens commented 5 years ago

Hi Tom

Thanks for informing me. I am still pretty new at developing. I'll look into it for sure.