我正在尝试为标记分配一个弹出窗口。我创建了一个弹出窗口并将其绑定到标记。然而,它并没有出现。我有一个出现的测试alert()
,但弹出窗口没有。
有人可以帮忙解决这个问题吗?
var lonLatMarker = new OpenLayers.LonLat( 78.447876 ,17.371610 )
.transform( new OpenLayers.Projection("EPSG:4326"), // transform from WGS 1984
map.getProjectionObject() // to Spherical Mercator Projection
);
var feature = new OpenLayers.Feature(markers, lonLatMarker);
feature.closeBox = true;
feature.popupClass = OpenLayers.Class(OpenLayers.Popup.AnchoredBubble, {
minSize: new OpenLayers.Size(300, 180)
} );
feature.data.popupContentHTML = 'Hello World';
feature.data.overflow = "hidden";
var marker = new OpenLayers.Marker(lonLatMarker);
marker.feature = feature;
var markerClick = function(evt) {
if (this.popup == null) {
this.popup = this.createPopup(this.closeBox);
map.addPopup(this.popup);
this.popup.show();
} else {
alert("Hello");
this.popup.toggle();
}
OpenLayers.Event.stop(evt);
};
marker.events.register("mousedown", feature, markerClick);
markers.addMarker(marker);
map.setCenter (lonLatMarker, 9);