From: Ken N. <ke...@ke...> - 2009-10-02 12:01:11
|
Just started using GWT-OpenLayers so I may be missing the obvious here. I need to implement a new handler for the map double click event (we just want to centre on the click location rather than zoom to it as is the default) I can do it easily enough in pure javascript openlayers But now I need to do it via gwt-openlayers I've got as far as the addMapClickListener code but this only allows me to handle a single click, as far as I can see I know not all addXxxListener methods have not been implemented so what is the best way for me to add the double click handler? Any sort of nudge in the general direction would be much appreciated Ken Needham |
From: Edwin C. <com...@gm...> - 2009-10-03 14:20:04
|
Hi Ken, I doesn't seem your missing the obvious. I guess the best way is to start from the OL clickhandler example. GWT-OL is missing a click control (which also isn't formally in OL, but would be convenient in GWT-OL) and it is also missing a wrapper for the clickhandler. How would you do it in pure javascript? Greetings, Edwin 2009/10/2 Ken Needham <ke...@ke...>: > Just started using GWT-OpenLayers so I may be missing the obvious here. > I need to implement a new handler for the map double click event (we just > want to centre on the click location rather than zoom to it as is the > default) > I can do it easily enough in pure javascript openlayers > But now I need to do it via gwt-openlayers > I've got as far as the addMapClickListener code but this only allows me to > handle a single click, as far as I can see > I know not all addXxxListener methods have not been implemented so what is > the best way for me to add the double click handler? > Any sort of nudge in the general direction would be much appreciated > Ken Needham > ------------------------------------------------------------------------------ > 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 > > |
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 |
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 > > |
From: Ken N. <ke...@ke...> - 2009-10-05 11:52:12
|
OK, I'll give that a goAssuming it all works I'll submit the changes for inclusion Might as well try to do it properly I suppose. Ken |
From: Edwin C. <com...@gm...> - 2009-10-05 12:57:59
|
Hi Ken, Let me know if it works. You can look at the EventHandlerImpl to see how the onHandle method of EventHandler is called from javascript. EventHandler and the code using it is documented with JavaDoc, so that may be a good place to look how the abstract class trick works. I would say that in the click handler case empty methods vs abstract methods would be best, because with abstract methods someone who provides an anonymous implementation would need to implement all abstract methods. Very kind that you consider contributing back your efforts. Greetings and good luck, Edwin 2009/10/5 Ken Needham <ke...@ke...>: > OK, I'll give that a go > Assuming it all works I'll submit the changes for inclusion > Might as well try to do it properly I suppose. > Ken > > > > |