单击标记时,OSM 弹出窗口不显示。我已经尝试过标记上的点击事件。它有效吗?建议我点击它时如何在标记上显示弹出窗口。
JS
我试过的代码
var newlonLat = new OpenLayers.LonLat( 78.447876 ,17.371610 )
.transform( new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
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);
newmarkers = new OpenLayers.Layer.Markers( "Markers" );
newmarkers.events.register('mouseover', newmarkers, function(evt) {
popup = new OpenLayers.Popup("chicken",
newlonLat,
new OpenLayers.Size(200,50),
"Location",
true);
map.addPopup(popup);
});
newmarkers.events.register('mouseout', newmarkers, function(evt) {
popup.hide();
});
map.addLayer(newmarkers);
newmarkers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(Tlon,Tlat).transform( fromProjection, toProjection),icon));