Render 2500 geoJSON polygons onto a leaflet map

前端 未结 4 1792
盖世英雄少女心
盖世英雄少女心 2021-02-01 00:01

I\'ve been searching but cannot seem to find a solution.

I have a GeoJSON file which is 170mb in size. It contains about 2500 polygons. Somehow I need to render it to a

4条回答
  •  无人及你
    2021-02-01 00:17

    The easiest way is to create your own map tiles based on that data. There are a couple of ways of achieving this but my suggestion is that you use TileMill. It's free and very easy to use. So, basically you would:

    • Use TileMill and specify your GeoJSON file as the data-source

    • Configure how the map should be displayed (like the color of the polygons) with a special CSS-like language inside TileMill

    • Generate the tiles

    • Load a new TileLayer in your Leaflet map that references your files

    I've actually written a tutorial some time ago that uses a .shp instead of a GeoJson, but should be similar enough:

    http://build-failed.blogspot.pt/2012/03/custom-map-tiles-part-2-tilemill.html

提交回复
热议问题