Tuesday, April 28, 2015

Re: Reading a local KML file in GWT?

What about using kml file into a ClientBundle  like this.

public interface MyResources extends ClientBundle {
  public static final MyResources INSTANCE =  GWT.create(MyResources.class);

  @Source("cta.ml")
  public TextResource myKml();

}

than you can access the data with

MyResources.INSTANCE.myKml().asText()



On Wednesday, April 15, 2015 at 3:17:48 PM UTC+2, mohit wrote:
I am trying to render KML layers on a google map in GWT. I have set up the geoxml.js file in my host html as : 

<script type="text/javascript" src="geoxml3.js"></script>

public final native JavaScriptObject createKmlParser(JavaScriptObject mapId) /*-{
var myParser = new $wnd.geoXML3.parser({
map : mapId
});
return myParser;
}-*/;

public final native void showKml(JavaScriptObject parser, String kml) /*-{
parser.parseKmlString(kml);
}-*/;

public final native void hideKml(JavaScriptObject parser) /*-{
parser.hideDocument();
}-*/;

public void setupKmlLayer(final MapWidget mapWidget) {
final JavaScriptObject jsoParser = createKmlParser(mapWidget.getJso());
try {
showKml(jsoParser, "cta.kml");
} catch (final JavaScriptException jse) {
Window.alert("javascript exception");
}
}

But I am always getting : javascript exception, the last line above.

Where should I put this cta.kml so that it gets picked up correctly??

Is there a better way to apply layers using local KML files.

Thanks

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment