|
From: Ken N. <ke...@ke...> - 2009-10-05 10:24:24
|
I have numerous changes to make to a (rather over complicated) GIS
application
The policy has been to leave the GWT-OpenLayers code untouched and to create
yet another layer on top in which we handle all the non-standard stuff.
In this case do you think I would be useful for me to add a new handler into
the GWT-OpenLayer code?
The pure OL JavaScript approach is as follows:
<html> <head>
<script type="text/javascript" src="
http://openlayers.org/api/OpenLayers.js"></script>
</head>
<body onload="loadmap();">
<script type="text/javascript">
function centre(evt, map){
var newCenter = map.getLonLatFromViewPortPx( evt.xy );
map.setCenter(newCenter);
}
function loadmap(){
//basic setup
var map = new OpenLayers.Map('map');
var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS", "
http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
map.addLayer(wms);
if (!map.getCenter()) map.zoomToMaxExtent();
//Create handler
var dblclick = new OpenLayers.Handler.Click(this, {
dblclick:function(evt) { centre(evt, map); } },
{'double': true,
stopDouble: true});
//Fix up the missing map reference
dblclick.setMap(map);
//Activate in correct order
dblclick.activate();
}
</script>
<div style="width:1000px; height:500px; border: 1px blue solid;"
id="map"></div>
<div id="eventlog"></div>
</body>
</html>
Ken
|