I am using leaflet to visualize several layers in the project. One layer(load from geojson format) contains thousands of small polygons, which has a very slow loading speed. I read this Visualizing large datasets with Leaflet, but it mainly deals with the markers. Is there a similar way to deal with polygon?

1 Answer 1


Firstly, check out this post. It may not be exactly what you want though, which is why I did not mark this thread for closure as a duplicate.

Secondly, there are a number of tactics you can employ in addition to the ones mentioned in the post. Simplifying the polygons can help to start with. Also, do you need to present the data as GeoJson? If not, then you could host it on a GeoServer instance and serve it as WMS. If you do need geoJSON, then you could consider hosting the data on Geoserver (or similar) and serve it as WFS but use bounding box requests to limit the amount of data pulled by the client.

If setting up Geoserver just for one dataset sounds like a sledgehammer to crack a nut, remember that Geoserver is very easy to set up and the time spent getting a basic instance up and running will probably be less than the effort to solve your huge GeoJson woes.

Thirdly, you can cut your GeoJson file in multiple files and only load the ones which are necessary depending on the view (unloading the others as you go)

  • 1
    thanks a lot, I use the first suggestion by changing the code(rectangle to polygon) a bit. It works perfect. Only trouble is when I extract coordinates from geojson, it has a format lonlat, but the polygon in leaflet accept latlon, which cost me a lot of time to debug. Aug 11, 2016 at 20:05
  • Ah! Yes that is a classic 'gotcha'. The correct GIS way is x then y, but popular parlance always goes 'latlon', which is wrong... but leaflet has bowed to peer pressure at the expense of GIS aficionados :) Aug 11, 2016 at 20:09
  • I'm not sure how does serving a WMF or WFS compared to GeoJSON is going to fix the problem? The simple conversion from one format to other is not probably going to bring as much performance gain. So I assume you mainly mean to take advantage of clipping and simplification features. Can these not be applied directly on GeoJSON format? why WMS and WFS?
    – mohamnag
    Sep 21, 2018 at 8:33
  • WFS and WMS are protocols (or 'services' as the names suggest) not data formats per se. So a WFS service can deliver data in a variety of formats and can efficiently handle portions of large datasets. This is not about merely changing data format but a delivery mechanism for large datasets. Sep 24, 2018 at 6:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.