[OpenLayers-Users] Capture coords onClick

Ivan Grcic igrcic at gmail.com
Tue Jun 16 02:59:05 EDT 2009


hi, some tips:

    document.getElementById('html_button').onclick = function (){
        clickHandler.activate();
    }

    var clickHandler = new OpenLayers.Handler.Click(
        { 'map': map },
        {
            'click': function(evt) {
               //get ur coords
                var lonlat = PARAMS.map.getLonLatFromViewPortPx(evt.xy);
              //do what u want with them
              ...
                //deactivate it
                clickHandler.deactivate();
            }
        }
    );


cheers
On Mon, Jun 15, 2009 at 9:53 PM, Heidt, Christopher
M.<CHRISTOPHER.M.HEIDT at saic.com> wrote:
> Whats the easiest way to capture coords on click?
>
> My Usage:
> I have a form with a location textfield.
> a button next to the field will allow a user to (once clicked) click on the
> map to fill the textfield with a lat, long ,alt.
> Alt will default to 0.
>
> I'm thinking i need to register and unregister a temporary click event,
> but I figured I'd ask how others have done this before I start digging into
> it.
> Being able to cancel with esc would be nice too, but not nessassary.
>
> Options?
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>



-- 
Ivan Grcic



More information about the Users mailing list