如何在180°子午线附近显示传单标记? [英] How to display Leaflet markers near the 180° meridian?

查看:68
本文介绍了如何在180°子午线附近显示传单标记?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Leaflet 1.0.0-rc.2 + e02b5c9.我知道默认值是渲染所有标记,折线...从屏幕上的经度-180到180,如下所示:

I am using Leaflet 1.0.0-rc.2+e02b5c9. I know the default is rendering all markers, polylines ... from longitude -180 to 180 as screen shot here:

但是,我想将地图显示为此时要显示的经度(这是日本和美国之间的中间海域):

However, I want to show the map as this longitude I want to show at this point (It is middle sea between Japan and US):

,但是您看到所有标记都未在右侧渲染.即使,如果我设置

but you see all the markers are not rendered on the right side. Even though, If i set

worldCopyJump: true

当我向右拖动时,所有标记都显示在右侧,但它们却消失在左侧,反之亦然.实际上,我希望它们同时出现.

when I drag to the right, all markers are appeared on the right but they are disappeared on the left and vice versa. Actually, I want they are appeared at the same time.

有任何解决办法吗?

推荐答案

只需确保标记的经度在0..360范围内,而不是在-180..180范围内. 看到一个有效的示例.

Just make sure that the longitudes of your markers are in the range 0..360 instead of in the range -180..180. See a working example.

即代替

L.marker([0,170]).addTo(map);
L.marker([0,-180]).addTo(map);
L.marker([0,-170]).addTo(map);

做类似的事情

L.marker([0,170]).addTo(map);
L.marker([0,180]).addTo(map);
L.marker([0,190]).addTo(map);

换句话说,如果经度小于零,则将其添加360.如果您打算一次过滤所有经度,则可能要使用L.Util.wrapNum(lng, [0,360], true).

In other words, if a longitude is smaller than zero, add 360 to it. You might want to use L.Util.wrapNum(lng, [0,360], true) instead, if you plan to filter all your longitudes at once.

这篇关于如何在180°子午线附近显示传单标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆