[OpenLayers-Users] Getting paramaters from events
Aaron Racicot
aaronr at z-pulley.com
Tue Mar 6 13:06:22 EST 2007
The callback gets called in the context of the object (i.e. Marker in your
case) and therefore you have access to the Marker data members as part of
the callback via this. Marker does not have an x or y member, but it does
have a lonlat that you can access.
this.lonlat.lon and this.lonlat.lat (or just lonlat.lon for that
matter)
If you want the click xy then you can access evt.xy.x and evt.xy.y
Hope that helps.
A
+----------------------------------------+
Aaron Racicot - GIS Programmer
360.221.2441 - aaronr at ecotrust.org
+----------------------------------------+
e c o t r u s t
pobox 1614
langley wa 98260
www.ecotrust.org
+----------------------------------------+
-----Original Message-----
From: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] On
Behalf Of Keith
Sent: Tuesday, March 06, 2007 9:29 AM
To: users at openlayers.org
Subject: [OpenLayers-Users] Getting paramaters from events
I'm having trouble passing parameters through an event call.
According to the browse repository: you should be able to retrieve previous
parameters from the callback function ( in this case "this.x/y" ).
I haven't had any luck with this so far though (this.x/y are "undefined").
Can anybody provide me with the appropriate way of retrieving parameters (as
passing them isn't an option).
I've included the "dumbed-down" debug code below.
<!---------------------------------------------------------------------->
function addMarker(x,y,layer) {
marker = new OpenLayers.Marker(
new OpenLayers.LonLat(x,y),
new
OpenLayers.Icon("/kamap/mapserver/images/AQUA.png",new
OpenLayers.Size(20,34))
);
layer.addMarker(marker);
marker.events.register("mousedown", marker, mousedown);
}
<!----------------------------------------------------------------------->
function mousedown(evt) {
document.write("DEBUG LINE : " + this.x);
document.write("____DEBUG LINE : " + this.y);
}
<!---------------------------------------------------------------------->
Thanks,
Keith Weber
Tech Support
Archetype, Inc.
205.443.6560 office
334.669.2522 mobile
kweber at archetypecorp.com
The information transmitted is the property of Archetype, Inc. and is
intended only for the person or entity to which it is addressed and may
contain confidential and/or privileged material. Statements and opinions
expressed in this e-mail may not represent those of the company. Any review,
retransmission, dissemination and other use of, or taking of any action in
reliance upon, this information by persons or entities other than the
intended recipient is prohibited. If you received this in error, please
contact the sender immediately and delete the material from any computer.
E-mail transmission cannot be guaranteed to be secured or error-free as
information could be intercepted, corrupted, lost, destroyed, received late
or incomplete, or could contain viruses. The sender therefore does not
accept liability for any error or omission in the contents of this message,
which arises as a result of e-mail transmission.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070306/7866396a/attachment.html
More information about the Users
mailing list