The second argument in the events.register correspond to the context
in which the callback will be executed. That means that by using the
"this" keyword in the callback you will access to object given as
context (scope).
In your case,
function markerClicked(evt) {
alert (this.icon.url); // will return the url of the icon of the
clicked marker
}
Do you need something more specific ?
Regards,
Pierre
On Fri, Mar 6, 2009 at 9:35 AM, Robert Collier
<[email protected]> wrote:
> I’m adding markers to a map, and I want to do things when they are clicked
> upon, so I’m doing this:
>
> var marker = new OpenLayers.Marker(lonLat,icon);
> sitelayer.addMarker(marker);
> marker.events.register("mousedown", marker, markerclicked);
>
> But I really want to be able to pass another variable to the callback aswell
> that identifies the particular marker, is there any way I can achieve
> something like:
>
> marker.events.register("mousedown", marker, markerclicked, myid);
> ...
> function markerclicked(evt, myid) {
> }
>
> Or get the same result (identify a specific marker from the callback).
>
> - Thanks, Robert Collier
>
> --
> Robert Collier
> Network Architect
> AlwaysON Group
>
> _______________________________________________
> Users mailing list
> [email protected]
> http://openlayers.org/mailman/listinfo/users
>
--
Pierre GIRAUD
http://www.camptocamp.com
Sent from: Paris J France.
_______________________________________________
Users mailing list
[email protected]
http://openlayers.org/mailman/listinfo/users