[OpenLayers-Users] How can I get a mobile browser to trap a click
event like I can for a PC web browser?
Richard Greenwood
richard.greenwood at gmail.com
Sun Oct 16 20:05:42 EDT 2011
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
More information about the Users
mailing list