简体   繁体   English

将GeoJSON对象包装在Leaflet.js地图周围

[英]Wrap GeoJSON objects around Leaflet.js map

I have a Leaflet.js map consisting of Marker and GeoJSON objects. 我有一个由MarkerGeoJSON对象组成的Leaflet.js映射。 Is there a simple way to wrap these so they appear periodically every 360 degrees? 有没有简单的方法可以包装这些文件,使它们每360度周期性出现一次? Basically, I want the entire map to become periodic. 基本上,我希望整个地图都具有周期性。

Here is an illustration of the sort of objects I have (excluding the background TileLayer , which I don't have): 这是我拥有的对象的一种图示(不包括背景TileLayer ,我没有):

破碎的大圆圈地图

How can I periodically repeat this data so the great circles aren't broken, but appear intact every 360 degrees as the map is scrolled left or right? 如何定期重复此数据,以使大圆环不被破坏,而是在向左或向右滚动地图时每360度完整显示?

One approach is to leverage Leaflet.VectorGrid . 一种方法是利用Leaflet.VectorGrid As you can see in the Leaflet.VectorGrid GeoJSON example , the data will wrap. 如您在Leaflet.VectorGrid GeoJSON示例所见 ,数据将包装。 (Architecturally, this happens because VectorGrid loads a vector tile with the same coordinates when wrapping around). (在架构上,发生这种情况是因为VectorGrid环绕时会加载具有相同坐标的矢量图块)。 Be advised that some artifacts might appear. 请注意,可能会出现一些工件。

Another approach is to simply duplicate your data (adding 360 to each longitude). 另一种方法是简单地复制数据(向每个经度添加360)。 Do it a couple of times per side, and use the WorldCopyJump option to prevent users from scrolling too far. 每边做几次,并使用WorldCopyJump选项来防止用户滚动太远。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM