My Code to add popups as selectControl to a Layer. Works fine! 


// SelectControl für Marker --> Popup
window.selectControl = new OpenLayers.Control.SelectFeature(
        [ window.markerLayer ]);


// code of: http://docs.openlayers.org/library/overlays.html#displaying-popups

function onPopupClose(evt) {

// 'this' is the popup


function onFeatureSelect(evt) {

feature = evt.feature;

var html_popup = "some html code";

popup = new OpenLayers.Popup.FramedCloud("featurePopup", feature.geometry
        .getBounds().getCenterLonLat(), new OpenLayers.Size(250, 220),
        html_popup, null, true, onPopupClose);

feature.popup = popup;
popup.feature = feature;


function onFeatureUnselect(evt) { feature = evt.feature; if (feature.popup) { popup.feature = null; map.removePopup(feature.popup); feature.popup.destroy(); feature.popup = null; } }

..But by clicking the closeButton on the Popup i am creating a new Marker because of this line:

    map.events.register("click", map, newMarkerClickEvent);

the Method: newMarkerClickEvent creates a new marker on the xy-Position of the event...

How can i prevent from firing the click-Event to the map on clicking the Popup-Button ??


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.