[OpenLayers-Users] Caputing left click when displaying google maps

John Preston byhisdeeds at gmail.com
Sun Aug 10 12:20:35 EDT 2008


Hi, I have the following code using OpenLayers 2.6 but I can't get the
left mouse click event to work with the google layers.

map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
map.addControl(new OpenLayers.Control.OverviewMap());
var gsat = new OpenLayers.Layer.Google(\"Google Satellite\", {type:
G_SATELLITE_MAP});
map.addLayers([gsat]);
map.setCenter(new OpenLayers.LonLat(-77.4, 18.2), 9);
map.events.register('click', map, function (e) {var lonlat =
map.getLonLatFromViewPortPx(e.xy);alert('You clicked near ' +
lonlat.lat + ' N, ' + lonlat.lon + ' E');})

Clicking the left mouse button does nothing. The code however works if
I use some other wms server layer.

Any ideas what I'm doing wrong?

John



More information about the Users mailing list