openlayers - Adding data to an open layers marker -
i'm using open street maps , open street layers , trying create map of tickets (markers) technician go marker , work , move next. able create marker , have onclick function fires. can't figure out how pull out information marker itself. creating markers like..
addpinvialonglat: function(icon, long, lat, popupstring) { var icon_marker = new openlayers.icon(icon, null, null); var marker = new openlayers.marker(new openlayers.lonlat(long, lat).transform(rapidschedulingmap.coor_from, rapidschedulingmap.coor_to), icon_marker); var popup; marker.events.register('mouseover', marker, function(evt) { popup = new openlayers.popup.framedcloud("popup", new openlayers.lonlat(long, lat).transform(rapidschedulingmap.coor_from, rapidschedulingmap.coor_to), null, popupstring, null, false); rapidschedulingmap.map.addpopup(popup); }); marker.events.register('mouseout', marker, function(evt) { popup.hide(); }); rapidschedulingmap.bindclick(marker); rapidschedulingmap.layer.addmarker(marker); },
i wondering if there way add data on click can reference marker.ticketnumber. haven't seen googling turned here. hope has ideas.
edit: found how remove specific marker in openlayer shows ability marker.xxxx , push markers array keep track of them all.
i found solution...
var marker = new openlayers.marker(new openlayers.lonlat(long, lat).transform(rapidschedulingmap.coor_from, rapidschedulingmap.coor_to), icon_marker); marker.data = data;
then when click on marker able marker.data , pull object stored each marker. no need array keep track of values.
Comments
Post a Comment