From: Edwin C. <com...@gm...> - 2009-03-05 15:16:54
|
Hi Brendan, Great that SelectFeature works fine. The problem with the KML format I will have to look into. Currently the Format support in GWT-OpenLayers is still limited. KML inherits it's write functionality from VectorFormat, but perhaps it's necessary to specify write options for KML that I was unaware of to. WKT should work. If that gives strange output to than sth else is going on. Greetings, Edwin 2009/3/5 Brendan Grady <bre...@gm...> > Hi Edwin - > > The SelectFeature appears to be working perfectly. Thanks! > > Implementing the editing features that are in > http://crschmidt.net/mapping/wpserverdemo/ would make for a very powerful > toolset. I would be happy to test out whatever you have. > > As an aside, this is how I tested out the Select Feauture: > > SelectFeatureOptions options = new SelectFeatureOptions(); > options.onSelect( new SelectFeature.SelectFeatureListener(){ > > public void onFeatureSelected(JSObject vectorFeature) { > VectorFeature overlay = > VectorFeature.narrowToVectorFeature(vectorFeature); > popup = new AnchoredBubble("vector-info", > new LonLat(0,0), > new Size(300, 400), > "<p>" + new KML().write(overlay) + "</p>", > new Icon("", new Size(0, 0), new Pixel(0, 0)), > true); > map.addPopup(popup); > } > > }); > > For some reason though, the info that popped up is not KML. It looks more > like this: > > OpenLayers exportExported on Thu Mar 5 08:49:56 > EST2009OpenLayers.Feature.Vector_262No description available-0.0703125, > 2.4609375 -0.703125,-20.390625 ... > > Am I using the KML exporter incorrectly? > > Thanks again, > > Brendan > > > > On Thu, Mar 5, 2009 at 5:43 AM, Edwin Commandeur < > com...@gm...> wrote: > >> Hi there, >> >> Selecting features happens with a control in OpenLayers. I saw in the >> GWT-OpenLayers codebase that we are not yet wrapping the SelectFeature >> control. By default the SelectFeature selects features on click and you can >> pass it options to select on hover. >> >> So: >> (1) we need to add support for the select feature control => ADDED 5 min >> ago >> >> I added a wrapper for SelectFeature, but did not thoroughly test it... >> Maybe you can try it out. >> >> One caveat: The onSelect and onUnselect callback methods do not hook in >> with the broader OpenLayers event system. By the latter I mean that for >> example Vector (a vector layer object) has an Event object to register and >> unregister events, while the onSelect and onUnselect are just callback >> methods of the Control. This is why I added the Listener interfaces to the >> Control itself and this is why the methods onSelectFeature and >> onUnselectFeature return a JSObject which is a VectorFeature that you have >> to narrow to a VectorFeature yourself inside the method e.g. >> new SelectFeatureListener(){ >> public void onSelectFeature(JSObject vectorFeature) { >> VectorFeature vf = >> VectorFeature.narrowToVectorFeature(vectorFeature); >> } >> >> (2) you then need to add a button to activate the SelectFeature control >> (and deactivate the other editing controls). >> >> Point (2) could be realised in two ways: (a) you should create your own >> editing toolbar using GWT (b) we could support adding controls to the >> Editing Toolbar. Option 2b is not yet in OpenLayers, but would not be very >> difficult to support this in GWT-OpenLayers. I guess that most people want >> an editing toolbar like this one: >> >> http://crschmidt.net/mapping/wpserverdemo/ >> >> I will look into point 2b shortly, but cannot promise to have anything >> ready overnight. >> >> Greetings, >> Edwin >> >> 2009/3/4 Brendan Grady <bre...@gm...> >> >>> Hello, >>> >>> >>> New user to gwt-openlayers. >>> >>> Does anyone have an example of adding a "select" listener to a Vector >>> layer? I am adding vectors using the Editing Toolbar. >>> >>> In openlayers, I would add something like the following: >>> >>> selectControl = new OpenLayers.Control.SelectFeature(overlayLayer, >>> {onSelect: onFeatureSelect, onUnselect: onFeatureUnselect}); >>> >>> >>> I tried the following, but I think I need to add something else to the >>> map to make the layer "selectable" as it does not seem to register that I am >>> over a selectable vector: >>> >>> <snip> >>> Vector overlayLayer = new Vector("Overlay Creation Layer"); >>> map.addLayer(overlayLayer); >>> map.addControl(new EditingToolbar(overlayLayer)); >>> >>> overlayLayer.addVectorFeatureSelectedListener( new >>> VectorFeatureSelectedListener(){ >>> >>> public void onFeatureSelected(Vector source, >>> FeatureSelectedEvent eventObject) { >>> VectorFeature overlay = eventObject.getFeature(); >>> popup = new AnchoredBubble("vector-info", >>> new LonLat(0,0), >>> new Size(300, 400), >>> "<p>" + new KML().write(overlay) + "</p>", >>> new Icon("", new Size(0, 0), new Pixel(0, 0)), >>> true); >>> map.addPopup(popup); >>> } >>> >>> }); >>> </snip> >>> >>> Any suggestions? >>> >>> Thanks, >>> Brendan >>> >>> >>> ------------------------------------------------------------------------------ >>> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, >>> CA >>> -OSBC tackles the biggest issue in open source: Open Sourcing the >>> Enterprise >>> -Strategies to boost innovation and cut costs with open source >>> participation >>> -Receive a $600 discount off the registration fee with the source code: >>> SFAD >>> http://p.sf.net/sfu/XcvMzF8H >>> _______________________________________________ >>> Gwt-openlayers-users mailing list >>> Gwt...@li... >>> https://lists.sourceforge.net/lists/listinfo/gwt-openlayers-users >>> >>> >> >> >> ------------------------------------------------------------------------------ >> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, >> CA >> -OSBC tackles the biggest issue in open source: Open Sourcing the >> Enterprise >> -Strategies to boost innovation and cut costs with open source >> participation >> -Receive a $600 discount off the registration fee with the source code: >> SFAD >> http://p.sf.net/sfu/XcvMzF8H >> _______________________________________________ >> Gwt-openlayers-users mailing list >> Gwt...@li... >> https://lists.sourceforge.net/lists/listinfo/gwt-openlayers-users >> >> > |