Leaflet 传单.JS标记位于对面地图的坐标上
不知道该怎么说,但当我把一个传单标记放在(我相信)64纬度标记的东面时,它会出现在地图的左边。我想让所有的标记都在同一张地图上 想象一下我所说的: 我想让左边的标记指向纬度和经度标记,它们需要位于其他标记所在的位置。你可以看到我画了一个箭头来表示它在哪里 我所尝试的: 我找不到任何东西,所以我尝试将worldCopyJump设置为false。然后我尝试了真的,但它并没有解决这个问题 谢谢 (哦,如果我放大该区域,它应该在,但它不会出现。) 代码: HTML:Leaflet 传单.JS标记位于对面地图的坐标上,leaflet,Leaflet,不知道该怎么说,但当我把一个传单标记放在(我相信)64纬度标记的东面时,它会出现在地图的左边。我想让所有的标记都在同一张地图上 想象一下我所说的: 我想让左边的标记指向纬度和经度标记,它们需要位于其他标记所在的位置。你可以看到我画了一个箭头来表示它在哪里 我所尝试的: 我找不到任何东西,所以我尝试将worldCopyJump设置为false。然后我尝试了真的,但它并没有解决这个问题 谢谢 (哦,如果我放大该区域,它应该在,但它不会出现。) 代码: HTML: JS var mymap=L.
JS
var mymap=L.map('mapid',{worldCopyJump:true}).setView([51.505,-0.09],3);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=api_key'{
/*最大缩放:7*/
属性:“映射数据©;贡献者”+
“图像”,
id:“地图盒/街道-v11”,
tileSize:512,
Zoomofset:-1,
//将以下行设置为false
}).addTo(mymap);
var presentIcon=L.icon({
iconUrl:'giftmarker.png',
图标大小:[38,60],//图标的大小
iconAnchor:[12,57],//将对应于标记位置的图标点
});
标记([65.585848,-171.011122],{icon:presentIcon}).addTo(mymap);
L.标记x60次您需要将360次添加到错误放置标记的
Lng
因此标记应该如下所示:L.marker([65.585848188.988878],{icon:presentIcon})代码>
使用此代码可以更改所有现有标记。我在-149液化天然气处休息,将标记交换到另一侧:
map.eachLayer((layer) => {
if (layer instanceof L.Marker) {
if (layer.getLatLng().lng <= -149) {
var latlng = layer.getLatLng();
latlng.lng = latlng.lng + 360;
layer.setLatLng(latlng);
}
}
});
map.eachLayer((层)=>{
if(L.Marker的图层实例){
if(layer.getLatLng().lng
var mymap = L.map('mapid', {worldCopyJump: true}).setView([51.505, -0.09], 3);
L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token=api_key', {
/*maxZoom: 7,*/
attribution: 'Map data © <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, ' +
'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
id: 'mapbox/streets-v11',
tileSize: 512,
zoomOffset: -1,
//set following lines to false
}).addTo(mymap);
var presentIcon = L.icon({
iconUrl: 'giftmarker.png',
iconSize: [38, 60], // size of the icon
iconAnchor: [12, 57], // point of the icon which will correspond to marker's location
});
L.marker([65.585848, -171.011122], {icon: presentIcon}).addTo(mymap);
map.eachLayer((layer) => {
if (layer instanceof L.Marker) {
if (layer.getLatLng().lng <= -149) {
var latlng = layer.getLatLng();
latlng.lng = latlng.lng + 360;
layer.setLatLng(latlng);
}
}
});