简体   繁体   中英

make kml layer from a string (GWT)

I have a KML in the form of a string. Actually I call a service from my GWT project and the service returns a KML file in the form of a string. How can I present this KML on my map? All I have is a string. Should I first parse it or can I create a KML layer from this string?

//I'm using google maps v3 api for GWT

I thought you were working in JavaScript, but since you are working in Java, have you taken a look at the JAK Java API for KML ? It uses JAXB under the covers, but it provides an unmarshal function that accepts either a file or a String . There is an article describing the library on TheServerSide.com and another article on Java.net .

And finally, there is some good and detailed documentation available at Micromata's JAK site . Hope this helps -

I'm trying to do the exact same thing you are. Check out this example from Google: KmlOverlayDemo.java .

You will have to write the string to a file (this would be best done on the server side) and then call GeoXmlOverlay.load("KmlFilePath", GeoXmlLoadCallback) . If successful, an overlay object is returned that you can just add to the MapWidget .

This is the best way I've found so far, but I'm searching for a better way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM