Leaflet.js - Draw polyline to nearest point from a location

て烟熏妆下的殇ゞ 提交于 2019-12-03 08:34:19

Here's a working jsfiddle that answers the line problem. There is a method attached to the LatLng object called wrap that is supposed to help. I had to experiment a bit to get it work. I settled on

if (Math.abs(loc1.lng - loc2.lng) > 180) {
  latlongs = [loc1.wrap(179, -179), loc2];
}

Unfortunately, as you can see, the marker for China isn't replicated. I added the worldCopyJump: true option to the map object, but it doesn't fix that particular problem. Not sure how to fix that.

Edit: For posterity's sake, I forgot to mention that the reason it wasn't working before was because of the transition over the International Date Line.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!