First off, you don't need to be an OpenLayers user to help me here.
I'm guessing some experience wrapping 3rd party api in GWT is what you
need to help me.
I've been using openlayers from GWT for the past couple months now.
I'm working off the GWT-OpenLayers project on sourceforge and wrapping
more openlayers functionality as I need it.
My work prompted me to wrap the OpenLayers LineString object, no big
problem, wrapped it as I had wrapped any other openlayers object -
keeping the same style as in the sourceforge project and making sure
it mirrored the openlayers api docs.
//LineString.java
public class LineString extends Curve {
protected LineString(JSObject element)
{
super(element);
}
public LineString(Point[] points)
{
this(LineStringImpl.create(pointsToArray(points))); //the
pointsToArray method is working happily, I tested this extensively.
}
...
//LineStringImpl.java
public class LineStringImpl {
public static native JSObject create(JSObject points)/*-{
return new $wnd.OpenLayers.Geometry.LineString(points);
}-*/;
...
The problem I have is that when i use my LineString object to create a
openlayers feature and then add it to a layer, it wont draw. There is
obviously some point inside the openlayers javascript where is fails
silently. It took me a lot of searching around to find a single post
about this problem (http://markmail.org/message/
khtjxmxr7hm3f6yj#query:openlayers%20GWT%20linestring+page:
1+mid:khtjxmxr7hm3f6yj+state:results). It turns out that passing
"points" to the LineString contructor wont work unless "points" is a
global js variable declared in plain javascript somewhere. My
workaround is:
//LineStringImpl.java
public class LineStringImpl {
public static native JSObject create(JSObject points)/*-{
for(i = 0; i < points.length; i++) {
$wnd.lsPoints[i] = points[i];
}
return new $wnd.OpenLayers.Geometry.LineString($wnd.lsPoints);
}-*/;
...
where "lsPoints" is declared inside of some <script> tags in my
ProjectName.HTML file before the nocache.js script tag.
This is a pretty horrible workaround, and I don't have a clue why I
even need to do this. Would someone be able to shed some light on the
cause of this and possibly suggest a more elegant workaround?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---