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"));
Document document = kml.createAndSetDocument(); Folder folder = document.createAndAddFolder(); GroundOverlay go = folder.createAndAddGroundOverlay();
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; }
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; }
Document document = kml.createAndSetDocument();