[OpenLayers-Users] How to program to drag markers

Adam Eskreis aeskreis at gmail.com
Thu Jul 7 17:31:32 EDT 2011


I believe all openlayers markers have a unique element ID (since they are
after all just DOM elements).  You should be able to get this ID from the
API available to you through the OpenLayers.Marker class.  I would then
attached mousedown and mouseup events to these markers, and use regular
javascript functions to change the positioning (I believe markers use
absolute positioning, so measuring the delta of mouse movements and altering
the left and top css properties should accomplish this).  Then just update
the lonlat of the marker when the mouse is released.

Should work theoretically anyway.

-Adam

On Thu, Jul 7, 2011 at 9:08 AM, JK Chen <jk.chen at sdl.usu.edu> wrote:

>  Hi,****
>
> ** **
>
> I have a bounding box that is displayed with two markers; one in NE corner,
> the other in SW corner. These two markers are added to marker layer using
> addMarker() api. ****
>
> ** **
>
> I would like to be able to drag the two markers, and receive events. How to
> do that? Anyone?****
>
> ** **
>
> The OpenLayers example page has a similar example but not exactly and is
> not applicable. It uses vector layer and uses DragFeature….. In my case mine
> are not features, but markers.****
>
> ** **
>
> Any idea is appreciated.****
>
> ** **
>
> Thanks.****
>
> ** **
>
> JK ****
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110707/8a15e99e/attachment.html


More information about the Users mailing list