From: Edwin C. <com...@gm...> - 2009-10-05 11:39:06
|
Hi Ken, It sounds reasonable that you want to keep all non standard stuff separate. If you would like to contribute a click handler that would be very welcome. From your code it seems a click control is not even necessary. The click handler should be an abstract class with empty callback functions, that can be overridden in an anonymous instance of the click handler. For example: abstract class ClickHandler extends JSObjectWrapper(){ //override public void onClick(ClickEventObject obj){}; } Then it needs to be instantiated like: new ClickHandler(){ public void onClick(){ //do sth here } } The javascript code would have to make a new javascript click handler that calls the empty callback methods on the abstract java click handler. That would be the first solution that would come to mind. If you would like to contribute a click handler or other such solution, then you would be more than welcome. I will not have time to work on it in the very near future. Greetings, Edwin 2009/10/5 Ken Needham <ke...@ke...> > 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 > > > > > ------------------------------------------------------------------------------ > Come build with us! The BlackBerry® Developer Conference in SF, CA > is the only developer event you need to attend this year. Jumpstart your > developing skills, take BlackBerry mobile applications to market and stay > ahead of the curve. Join us from November 9-12, 2009. Register now! > http://p.sf.net/sfu/devconf > _______________________________________________ > Gwt-openlayers-users mailing list > Gwt...@li... > https://lists.sourceforge.net/lists/listinfo/gwt-openlayers-users > > |