views:

257

answers:

2

I want to know that can I pass KML as a string to google map application?

Code snippet:

//KML String
 String document = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><kml xmlns=\"http://www.opengis.net/kml/2.2\"&gt;&lt;Document&gt;&lt;Folder&gt;&lt;name&gt;Paths&lt;/name&gt;&lt;open&gt;0&lt;/open&gt;&lt;Placemark&gt;&lt;LineString&gt;&lt;tessellate&gt;1&lt;/tessellate&gt;&lt;coordinates&gt; -112.0814237830345,36.10677870477137,0 -112.0870267752693,36.0905099328766,0</coordinates></LineString></Placemark></Folder></Document></kml>";

//Invoke Google Maps

int module = CodeModuleManager.getModuleHandle("GoogleMaps");

if (module == 0) {
  try {
    throw new ApplicationManagerException("GoogleMaps isn't installed");
  } catch (ApplicationManagerException e) {
    System.out.println(e.getMessage());
  } 
}

String[] args = {document}; //Is this possible???
ApplicationDescriptor descriptor = CodeModuleManager.getApplicationDescriptors(module)[0];
ApplicationDescriptor ad2 = new ApplicationDescriptor(descriptor, args);
try {
     ApplicationManager.getApplicationManager().runApplication(ad2, true);
    } catch (ApplicationManagerException e) {
      System.out.println(e.getMessage());
 }
A: 

After much R&D...the answer that I found out was that - No, we cannot pass KML as string.

Google Maps Mobile accepts a URL parameter. This needs to be in the form of "http://" and could be either specific parameters (such as "http://gmm/x?....") or a KML file ("http://..../sample.kml").

Pria
A: 

I was looking for this! thanks!:D

mer