简体   繁体   English

Openlayer-无法在标记上弹出绑定

[英]Openlayer - Unable bind popup on marker

I have tried to create popup for marker. 我试图为标记创建弹出窗口。 But it's displaying some where else in the map as shown in the figure. 但是它在地图上显示了其他位置,如图所示。 Am bit of confused in this scenario. 在这种情况下有点困惑。 Please give me solution. 请给我解决方法。

在此处输入图片说明

JS code i have tried 我尝试过的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);

I think you are giving wrong coordinations to popup. 我认为您对弹出式窗口的协调不正确。 Did you try to define popup like this?: 您是否尝试过这样定义弹出窗口?:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM