/** * Create an instance of {@link Kml} * */ public static Kml createKml() { return new Kml(); }
/** * Create an instance of {@link Kml} * */ public static Kml createKml() { return new Kml(); }
Marshaller m = JAXBContext.newInstance(new Class[] { Kml.class }).createMarshaller(); m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, true ); m.setProperty( Marshaller.JAXB_FRAGMENT, false ); m.setProperty(javax.xml.bind.Marshaller.JAXB_ENCODING, "UTF-8"); final Kml kml = new Kml(); kml.createAndSetPlacemark() .withName("London, UK").withOpen(Boolean.TRUE) .createAndSetPoint().addToCoordinates(-0.126236, 51.500152); StringWriter sw = new StringWriter(); m.marshal(kml,sw); String s1 = sw.toString(); System.out.println(s1);
final Kml kml = new Kml(); Document document = kml.createAndSetDocument(); listForms = formDAO.getAll(); for (Form list : listForms){ document.createAndAddPlacemark() .withName(String.valueOf(list.getId())) .withDescription(list.toStringKML()) .createAndSetPoint().addToCoordinates(-20.3978398, -43.5146653); } kml.setFeature(document); kml.marshal(new File("test.kml"));
final Kml __balloonKML = new Kml();
final Kml kml = new Kml(); final Folder folder = new Folder(); kml.setFeature(folder); folder.setName("Folder.kml"); folder.setOpen(true); final Placemark placemark1 = new Placemark().withId("1") .withName("Folder object 1 (Placemark)"); folder.getFeature().add(placemark1); final Placemark placemark2 = new Placemark().withId("2") .withName("Folder object 2 (Placemark)"); folder.getFeature().add(placemark2); List<Feature> features = folder.getFeature(); System.out.println(features); // dumps two features for(int i=features.size()-1; i >= 0; i--) { Feature f = features.get(i); if("1".equals(f.getId())) { // this removes feature with id = "1" features.remove(i); break; } } System.out.println(features); // folder now only has one item
throws IOException { Kml kml = new Kml(); Document document = kml.createAndSetDocument(); Folder folder = document.createAndAddFolder();
public Kml buildKMLDocument() { // prepare kml, document and folder Kml kml = new Kml(); Document document = kml.createAndSetDocument(); Map formatOptions = context.getRequest().getFormatOptions(); String kmltitle = (String) formatOptions.get("kmltitle"); if(kmltitle == null) { kmltitle = context.getMapContent().getTitle(); } document.setName(kmltitle); // get the callbacks for the document and let them loose List<KmlDecorator> decorators = context.getDecoratorsForClass(Document.class); for (KmlDecorator decorator : decorators) { document = (Document) decorator.decorate(document, context); if (document == null) { throw new ServiceException("Coding error in decorator " + decorator + ", document objects cannot be set to null"); } } encodeDocumentContents(document); return kml; }
Kml kml = new Kml(); Document document = kml.createAndSetDocument();
/** * Builds a lazily evaluated KML document given a encoding context * * @param context * @return */ public Kml buildKMLDocument(KmlEncodingContext context) { // prepare kml, document and folder Kml kml = new Kml(); Document document = kml.createAndSetDocument(); String kmltitle = (String) context.getRequest().getFormatOptions().get("kmltitle"); document.setName(kmltitle); // get the callbacks for the document and let them loose List<KmlDecorator> decorators = context.getDecoratorsForClass(Document.class); for (KmlDecorator decorator : decorators) { document = (Document) decorator.decorate(document, context); if (document == null) { throw new ServiceException("Coding error in decorator " + decorator + ", document objects cannot be set to null"); } } // create a generator that will generate a folder and feature dumps/ground overlays for each // layer SequenceFactory<Feature> generatorFactory = new PlainFolderSequenceFactory(context); SequenceList<Feature> folders = new SequenceList<Feature>(generatorFactory); context.addFeatures(document, folders); return kml; }
Kml kml = new Kml(); Document document = kml.createAndSetDocument();