我试图为标记创建弹出窗口。但它正在显示地图中的其他位置,如图所示。 在这种情况下有点困惑。 请给我解决方案。
我试过的
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);
答案 0 :(得分:1)
我认为你给弹出窗口提供了错误的坐标。您是否尝试像这样定义弹出窗口?:
popup = new OpenLayers.Popup("chicken",
newlonLat,
new OpenLayers.Size(200,200),
"example popup",
true);