問題描述
我一直在尋找,但似乎找不到解決方案.
I've been searching but cannot seem to find a solution.
我有一個 170mb 大小的 GeoJSON 文件.它包含大約 2500 個多邊形.不知何故,我需要將它渲染到傳單地圖.顯然我沒有機會.
I have a GeoJSON file which is 170mb in size. It contains about 2500 polygons. Somehow I need to render it to a leaflet map. Evidently at that size I have no chance.
呈現這些數據的最簡單方法是什么?我是否能夠創建一個完整的透明 png,它可以簡單地呈現在世界地圖上.巨大的尺寸是由于復雜性和多邊形的數量.在這一點上,我不需要它是交互式的.
What will the easiest way to render this data? Am I able to create a complete transparent png which can simply be rendered over the world map. The huge size is due to the complexity and the number of polygons. At this point I don't need it to be interactive.
謝謝,布賴恩
推薦答案
最簡單的方法是根據這些數據創建自己的地圖圖塊.有幾種方法可以實現,但我的建議是您使用 TileMill.它是免費的,而且非常易于使用.所以,基本上你會:
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:
使用 TileMill 并將您的 GeoJSON 文件指定為數據源
Use TileMill and specify your GeoJSON file as the data-source
在 TileMill 中使用特殊的類似 CSS 的語言配置地圖的顯示方式(如多邊形的顏色)
Configure how the map should be displayed (like the color of the polygons) with a special CSS-like language inside TileMill
生成圖塊
在您的 Leaflet 地圖中加載一個新的 TileLayer 以引用您的文件
Load a new TileLayer in your Leaflet map that references your files
實際上我前段時間寫過一個使用 .shp 而不是 GeoJson 的教程,但應該足夠相似:
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
這篇關于將 2500 個 geoJSON 多邊形渲染到傳單地圖上的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!