gpt4 book ai didi

javascript - Openlayer - 无法在标记上绑定(bind)弹出窗口

转载 作者:行者123 更新时间:2023-11-28 02:09:14 26 4
gpt4 key购买 nike

我尝试为标记创建弹出窗口。但它显示了 map 中的其他一些位置,如图所示。在这种情况下有点困惑。请给我解决方案。

enter image description here

JS 我尝试过的代码

var newlonLat = new OpenLayers.LonLat( Lon1, Lat1 )
.transform( new OpenLayers.Projection("EPSG:4326"),
map.getProjectionObject() // to Spherical Mercator Projection
);
var zoom=9;
var newmarkers = new OpenLayers.Layer.Markers( "Markers" );
map.addLayer(newmarkers);
newmarkers.addMarker(new OpenLayers.Marker(newlonLat));
map.setCenter (newlonLat, zoom);


popup = new OpenLayers.Popup("chicken",
new OpenLayers.LonLat(Lon1, Lat1),
new OpenLayers.Size(200,200),
"example popup",
true);

map.addPopup(popup);

最佳答案

我认为您对弹出窗口的协调是错误的。您是否尝试像这样定义弹出窗口?:

popup = new OpenLayers.Popup("chicken", 
newlonLat,
new OpenLayers.Size(200,200),
"example popup",
true);

关于javascript - Openlayer - 无法在标记上绑定(bind)弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17346306/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com