简体   繁体   中英

Add custom link to openlayer maps Marker

Hello can some one tell me how to add a custom link to openlayer maps marker? I want to be able to open a hidden div when i press the marker. I am trying to do something like this http://www.porcelanosa.com/showroom-locator however i can only add simple information via the pop up feature of the marker via text file. Right now i am using the WP plugin (OpenStreetMap Plugin V2.4.1). I tried multiple examples however none of them shows how to add a custom link to the marker

you can register a listener on your marker. A full example can be found here: Markers Layer Example .

marker.events.register('mousedown', marker, 
    function(evt) { 
        alert(this.icon.url); OpenLayers.Event.stop(evt); 
    }
);

if you are using a vector layer, you could register a feature selection event on it:

var myLayer = new OpenLayers.Layer.Vector(locale.layerStationMarkers, {
    eventListeners: {
        "featureselected": onFeatureSelectMethod(),
        "featureunselected": onStationFeatureUnselect()
    }
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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