我正在使用 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.
有什么办法可以解决这个问题吗?
Any ideas to fix that??
只要确保标记的经度在 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° 子午线附近显示传单标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
Browserify,Babel 6,Gulp - 传播运算符上的意外令牌Browserify, Babel 6, Gulp - Unexpected token on spread operator(Browserify,Babel 6,Gulp - 传播运算符上的意外令牌)
是否可以将标志传递给 Gulp 以使其以不同的方式Is it possible to pass a flag to Gulp to have it run tasks in different ways?(是否可以将标志传递给 Gulp 以使其以不同的方式运行任务
为什么我们需要在全局和本地安装 gulp?Why do we need to install gulp globally and locally?(为什么我们需要在全局和本地安装 gulp?)
如何一个接一个地依次运行 Gulp 任务How to run Gulp tasks sequentially one after the other(如何一个接一个地依次运行 Gulp 任务)
打开 Javascript 文件时 Visual Studio 2015 崩溃Visual Studio 2015 crashes when opening Javascript files(打开 Javascript 文件时 Visual Studio 2015 崩溃)
检测 FLASH 插件崩溃Detect FLASH plugin crashes(检测 FLASH 插件崩溃)