Open KML from a Link object


Any help greatly appreciated. I am try to use a Link object to open a KML stream directly in Google Earth.
Essentially my writer object produces some KML. I then want to get the OS native application to open the KML using Google Earth in this case.

private Link generateLink()
Kml kml = new Kml();

// Create a folder
Folder folder = kml.createAndSetFolder().withName(“AIME Google”)

// Add the entities network link
de.micromata.opengis.kml.v_2_2_0.Link entityUrl = new de.micromata.opengis.kml.v_2_2_0.Link()

  • “ENTITY.kml?mode=MIL_STD_2525B&side=ALL&balloon=FULL&emissions=ON”)

// Add the trails network link
de.micromata.opengis.kml.v_2_2_0.Link trailsUrl = new de.micromata.opengis.kml.v_2_2_0.Link()
.withHref(url + “TRAILS.kml”)

// Add the Link 16 network link
de.micromata.opengis.kml.v_2_2_0.Link link16Url = new de.micromata.opengis.kml.v_2_2_0.Link()
.withHref(url + “Link16.kml”)
folder.createAndAddNetworkLink().withName(“Link 16”).withOpen(true)

StringWriter writer = new StringWriter();

ExternalResource er = new ExternalResource(writer.toString(),
Link link = new Link(“AIME Google Earth link”, er);

return link;