From: Edwin C. <com...@gm...> - 2010-03-10 20:14:28
|
Hi Mikael, The gwt_openlayers_util.relay.createPolygon function is used to work around the issue that some OpenLayers functions/constructors check whether an argument is truly a javascript array using instanceof (var a = []; a instanceof Array). There are some other relay functions as well, see below. Unfortunately, an Array created using GWT, even if created using JSNI, does not pass this instanceof test (a javascript construct). If you create an array with JSNI then GWT somehow makes an Object out of it. Possibly in order to emulate Java client side. JavaScriptObject javascriptObject = JavaScriptObject.createArray(); where the createArray method is implemented as a JSNI function going sth like this: public static native JavaScriptObject createArray()/*-{ return []; }-*/; You will find the relay utility functions in 'util.js', which is distributed with GWT-OL src/main/java/org/gwtopenmaps/openlayers/public/js/gwt-openlayers/util.js Greetings, Edwin On 10 March 2010 15:32, Mikael Couzic <mik...@cl...> wrote: > Hi all, > > > I was creating a MultiPolygon class in the geometry package, and to get some > inspiration I was looking at the Polygon and PolygonImpl classes. In the > PolygonImpl.create(rings) method, I expected to see something like : > create(JSObject rings)/*-{ > return new wnd.OpenLayers.Geometry.Polygon(rings); > }-*/; > > However, here's what I found : > create(JSObject rings)/*-{ > return new $wnd.gwt_openlayers_util.relay.createPolygon(rings); > }-*/; > > My problem is that I have absolutely no idea how this works, and I don't > know where and what to look for. I'm still going to try and wrap the > MultiPolygon, but I suspect I'm not going to succed until I resolve this > mystery. > > Do you guys have any advice ? > > > -- > Mikael Couzic > Pôle Business Intelligence > Groupe Cliris > > ------------------------------------------------------------------------------ > Download Intel® Parallel Studio Eval > Try the new software tools for yourself. Speed compiling, find bugs > proactively, and fine-tune applications for parallel performance. > See why Intel Parallel Studio got high marks during beta. > http://p.sf.net/sfu/intel-sw-dev > _______________________________________________ > Gwt-openlayers-devl mailing list > Gwt...@li... > https://lists.sourceforge.net/lists/listinfo/gwt-openlayers-devl > > |