From: Andrew H. <ahh...@gm...> - 2010-06-09 01:16:16
|
I tried the following (in Map): /** * This will fetch all of the controls on the map. * @return the Controls or an empty array. */ public Control[] getControls(){ JSObject[] jsObjects = getJSObject().getPropertyAsArray("controls"); int count = jsObjects.length; Control[] controls = new Control[count]; for(int i =0; i < count ;i++){ controls[i] = Control.narrowToControl(jsObjects[i]); } return controls; } But this doesn't work, I'm out of my depth with JSNI... java.lang.IllegalArgumentException: Something other than a Java object was returned from JSNI method '@org.gwtopenmaps.openlayers.client.util.JSObjectHelper::getProperty(Lorg/gwtopenmaps/openlayers/client/util/JSObject;Ljava/lang/String;)': JS value of type int, expected java.lang.Object at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:178) at com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:266) at com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:91) at org.gwtopenmaps.openlayers.client.util.JSObjectHelper.getProperty(JSObjectHelper.java) at org.gwtopenmaps.openlayers.client.util.JSObject$.getProperty$(JSObject.java:100) at org.gwtopenmaps.openlayers.client.util.JSObject$.getPropertyAsArray$(JSObject.java:141) at org.gwtopenmaps.openlayers.client.Map.getControls(Map.java:124) Any help would be greatly appreciated :) On Tue, Jun 8, 2010 at 5:58 AM, Edwin Commandeur <com...@gm... > wrote: > Hi Andrew, > > That would be easy to add as a method to the Map, and it seems to make > sense. Controls are stored in an array on the map. We need to get the > JSObjects, narrow them to controls and return them in a Collection. I > guess there is no method for that in OpenLayers because accessing the > controls array is so easy in Javascript. > > Greetings, > Edwin > > On 7 June 2010 09:01, Andrew Hughes <ahh...@gm...> wrote: > > Hi Guys, > > I need to be able to manipulate all the controls on a map, but I can't do > > anything like... map.getControls(); any ideas? > > Cheers > > --AH > > p.s. I really need to iterate over all controls and remove the ones I > don't > > want. > > > ------------------------------------------------------------------------------ > > ThinkGeek and WIRED's GeekDad team up for the Ultimate > > GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the > > lucky parental unit. See the prize list and enter to win: > > http://p.sf.net/sfu/thinkgeek-promo > > _______________________________________________ > > Gwt-openlayers-users mailing list > > Gwt...@li... > > https://lists.sourceforge.net/lists/listinfo/gwt-openlayers-users > > > > > |