Hi all,
I attempt to realize the following scenario: A User wants to generate a
buffer around a self chosen point in the map. The pixel should be received
by a mouseDown event so that the Lonlat ist read by
getLonLatFromViewPortPx(evt.xy) on a mousedown-event. The User now can move
the mouse to set a distance to the first point and on mouseUp again the
LonLat should be read.
Afterwards i calculate the distance and produce a buffer around the first
point, using the distance as radius.
My Problem ist, that this works well with two click-events, but not with the
mousedown and mouseup of the drag handler.
My code:
....
this.handler = new OpenLayers.Handler.Drag(
this, {
'down':this.open,
'up':this.distance
}, this.handlerOptions
open: function(evt) {
var lonlat =
map.getLonLatFromViewPortPx(evt.xy);
YKoordinate =
lonlat.lat;
XKoordinate =
lonlat.lon;
},
distance: function(e) {
var lonlat2 =
map.getLonLatFromViewPortPx(e.xy);
XKoordinate2 = lonlat2.lon;
YKoordinate2 = lonlat2.lat;
//.... calculate distance, process buffer
},
CLASS_NAME:
"OpenLayers.Control.BufferButton"
});
Firebug says, that lonlat and lonlat2 are null.
Can somebody please help me? Is it really impossible to get the
mouseposition with down and up events? or is there any kind of workaround?
Thanks in advance!
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/getLonLatFromViewPortPx-with-drag-handler-tp5728236p5728236.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users