[OpenLayers-Users] How can I get a mobile browser to trap a click event like I can for a PC web browser?

John Mitchell mitchelljj98 at gmail.com
Tue Oct 18 11:30:34 EDT 2011


I tried using the suggested below code but I get an *OpenLayers.Control.Click
is not a constructor* error:

*var click = new OpenLayers.Control.Click( {
   trigger: function(e) {
      // do your thing
   }
});
map.addControl(click);
click.activate();*


John


On Sun, Oct 16, 2011 at 8:05 PM, Richard Greenwood <
richard.greenwood at gmail.com> wrote:

> On Sun, Oct 16, 2011 at 5:11 PM, John Mitchell <mitchelljj98 at gmail.com>
> wrote:
> > I am using openlayers 2.11 and I am able to trap the click event (See
> below
> > code) from a PC web browser but within an ipad2 the click event does not
> get
> > trapped.
> >
> > I have tried using the map.addControl(new
> OpenLayers.Control.Navigation());
> > and map.addControl(new OpenLayers.Control.TouchNavigation()); and for
> both
> > cases I get the same result described above.
> >
> > How can I get a mobile browser to trap a click event like I can for a PC
> web
> > browser?
> >
> > Thanks,
> >
> > John
> >
> >             map.events.register('click', map, function (e) {
> >                 updateMapState();
> >                     var xys = map.getLonLatFromViewPortPx(e.xy);
> >                     var easting = xys.lon;
> >                     var northing = xys.lat;
> >                     var point = new OpenLayers.LonLat(easting,northing);
> >                     getFeatureInfoForLonLat(point);
> >                     Event.stop(e);
> >             });
> >
>
>
> Use the OpenLayers.Control.Click something like the following:
>
> var click = new OpenLayers.Control.Click( {
>    trigger: function(e) {
>       // do your thing
>    }
> });
> map.addControl(click);
> click.activate();
>
>
> --
> Richard Greenwood
> richard.greenwood at gmail.com
> www.greenwoodmap.com
>



-- 
John J. Mitchell
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20111018/73b28809/attachment.html


More information about the Users mailing list