|
Key
This line was removed.
This word was removed. This word was added.
This line was added.
|
Comment:
Changes (1)
View Page History... {composition-setup} deck.width = 633px; {composition-setup} |
| {section} {column:width=70%} |
| !labs:home^spaceheader.jpg! |
| h2. Java API for KML - Examples {toc:minLevel=3|maxLevel=5|type=flat} |
... h3. {{<Abstract>}} This page contains examples. A lot of examples! It has a similar structure as [Google's KML reference|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html]. The [KML reference|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html] is an alphabetical reference for all KML elements defined in KML Version 2.2, as well as elements in the Google extension namespace. It describes the purpose of each element and gives (in most cases) a short KML usage example. JAK's example-page shows the Java counterpart to (almost) each KML example listed on the [KML reference|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html] page. h3. {{<BallonStyle>}} Original example can be found here: [{{<BalloonStyle>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#balloonstyle] {deck:id=BallonStyle} {card:label=Fluent example} {code:title=Listing BallonStyle (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument() .withName("BalloonStyle.kml").withOpen(true); document.createAndAddStyle() .withId("exampleBalloonStyle") .createAndSetBalloonStyle() .withId("ID") .withBgColor("ffffffbb") .withTextColor("ff000000") .withText("<![CDATA[" + "<b><font color='#CC0000' size='+3'>$[name]</font></b>" + "<br/><br/>" + "<font face='Courier'>$[description]</font>" + "<br/><br/>" + "Extra text that will appear in the description balloon" + "<br/><br/>" + "<!-- insert the to/from hyperlinks -->" + "$[geDirections]]]>"); final Placemark placemark = document.createAndAddPlacemark() .withName("BalloonStyle") .withDescription("An example of BalloonStyle") .withStyleUrl("#exampleBalloonStyle"); final Point point = placemark.createAndSetPoint(); List<Coordinate> coord = point.createAndSetCoordinates(); coord.add(new Coordinate(-122.370533,37.823842,0)); {code} {card} {card:label=POJO example} {code:title=Listing BallonStyle (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); kml.setFeature(document); document.setName("BalloonStyle.kml"); document.setOpen(true); final Style style = new Style(); document.getStyleSelector().add(style); style.setId("exampleBalloonStyle"); final BalloonStyle balloonstyle = new BalloonStyle(); style.setBalloonStyle(balloonstyle); balloonstyle.setId("ID"); balloonstyle.setBgColor("ffffffbb"); balloonstyle.setTextColor("ff000000"); balloonstyle .setText("<![CDATA[" + "<b><font color='#CC0000' size='+3'>$[name]</font></b>" + "<br/><br/>" + "<font face='Courier'>$[description]</font>" + "<br/><br/>" + "Extra text that will appear in the description balloon" + "<br/><br/>" + "<!-- insert the to/from hyperlinks -->" + "$[geDirections]]]>"); final Placemark placemark = new Placemark(); document.getFeature().add(placemark); placemark.setName("BalloonStyle"); placemark.setDescription("An example of BalloonStyle"); placemark.setStyleUrl("#exampleBalloonStyle"); final Point point = new Point(); placemark.setGeometry(point); final List<Coordinate> coord = new ArrayList<Coordinate>(); point.setCoordinates(coord); coord.add(new Coordinate(-122.370533,37.823842,0)); {code} {card} {card:label=KML output} {code:xml|title=Listing BallonStyle.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Document> <name>BalloonStyle.kml</name> <open>true</open> <Style id="exampleBalloonStyle"> <BalloonStyle id="ID"> <bgColor>ffffffbb</bgColor> <textColor>ff000000</textColor> <text><![CDATA[<b><font color='#CC0000' size='+3'>$[name]</font></b><br/><br/><font face='Courier'>$[description]</font><br/><br/>Extra text that will appear in the description balloon<br/><br/><!-- insert the to/from hyperlinks -->$[geDirections]]]></text> </BalloonStyle> </Style> <Placemark> <name>BalloonStyle</name> <description>An example of BalloonStyle</description> <styleUrl>#exampleBalloonStyle</styleUrl> <Point> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.370533,37.823842</coordinates> </Point> </Placemark> </Document> </kml> {code} {card} {deck} h3. {{<Camera>}} Original example can be found here:[{{<Camera>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#camera] {deck:id=Camera} {card:label=Fluent example} {code:title=Listing Camera (as fluent). } final Camera camera = KmlFactory.createCamera() .withId("ID") .withLongitude(0.0) .withLatitude(0.0) .withAltitude(0.0) .withHeading(0.0) .withTilt(0.0) .withRoll(0.0) .withAltitudeMode(AltitudeMode.CLAMP_TO_GROUND); {code} {card} {card:label=POJO example} {code:title=Listing Camera (as POJOs). } final Camera camera = new Camera(); camera.setId("ID"); camera.setLongitude(0.0); camera.setLatitude(0.0); camera.setAltitude(0.0); camera.setHeading(0.0); camera.setTilt(0.0); camera.setRoll(0.0); camera.setAltitudeMode(AltitudeMode.CLAMP_TO_GROUND); {code} {card} {card:label=KML output} {code:xml|title=Listing Camera.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Camera id="ID"> <longitude>0.0</longitude> <latitude>0.0</latitude> <altitude>0.0</altitude> <heading>0.0</heading> <tilt>0.0</tilt> <roll>0.0</roll> <altitudeMode>clampToGround</altitudeMode> </Camera> {code} {card} {deck} h3. {{<Document>}} Original example can be found here:[{{<Document>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#document] {deck:id=Document} {card:label=Fluent example} {code:title=Listing Document (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument().withName("Document.kml").withOpen(true); final Style style = document.createAndAddStyle().withId("exampleStyleDocument"); final LabelStyle labelStyle = style.createAndSetLabelStyle().withColor("ff0000cc"); final Placemark placemark1 = document.createAndAddPlacemark().withName("Document Feature 1").withStyleUrl("#exampleStyleDocument"); placemark1.createAndSetPoint().createAndSetCoordinates().add(new Coordinate(-122.371,37.816,0)); final Placemark placemark2 = document.createAndAddPlacemark().withName("Document Feature 2").withDescription("An example of BalloonStyle").withStyleUrl("#exampleStyleDocument"); placemark2.createAndSetPoint().createAndSetCoordinates().add(new Coordinate(-122.370,37.817,0)); {code} {card} {card:label=POJO example} {code:title=Listing Document (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); kml.setFeature(document); document.setName("Document.kml"); document.setOpen(true); final Style style = new Style(); document.getStyleSelector().add(style); style.setId("exampleStyleDocument"); final LabelStyle labelStyle = new LabelStyle(); style.setLabelStyle(labelStyle); labelStyle.setColor("ff0000cc"); final Placemark placemark1 = new Placemark(); document.getFeature().add(placemark1); placemark1.setName("Document Feature 1"); placemark1.setStyleUrl("#exampleStyleDocument"); final Point point1 = new Point(); placemark1.setGeometry(point1); List<Coordinate> coord1 = new ArrayList<Coordinate>(); point1.setCoordinates(coord1); coord1.add(new Coordinate(-122.371,37.816,0)); final Placemark placemark2 = new Placemark(); document.getFeature().add(placemark2); placemark2.setName("Document Feature 2"); placemark2.setDescription("An example of BalloonStyle"); placemark2.setStyleUrl("#exampleStyleDocument"); final Point point2 = new Point(); placemark2.setGeometry(point2); List<Coordinate> coord2 = new ArrayList<Coordinate>(); point2.setCoordinates(coord2); coord2.add(new Coordinate(-122.370,37.817,0)); {code} {card} {card:label=KML output} {code:xml|title=Listing Document.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Document> <name>Document.kml</name> <open>true</open> <Style id="exampleStyleDocument"> <LabelStyle> <color>ff0000cc</color> <scale>0.0</scale> </LabelStyle> </Style> <Placemark> <name>Document Feature 1</name> <styleUrl>#exampleStyleDocument</styleUrl> <Point> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.371,37.816</coordinates> </Point> </Placemark> <Placemark> <name>Document Feature 2</name> <description>An example of BalloonStyle</description> <styleUrl>#exampleStyleDocument</styleUrl> <Point> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.37,37.817</coordinates> </Point> </Placemark> </Document> </kml> {code} {card} {deck} h3. {{<ExtendedData>}} Original example can be found here:[{{<ExtendedData>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#extendeddata] {deck:id=ExtendedData1} {card:label=Fluent example} {code:title=Listing ExtendedData Value (as fluent). } final Placemark placemark = KmlFactory.createPlacemark().withName("Club house"); placemark.createAndSetExtendedData() .addToData(KmlFactory.createData("1").withName("holeNumber")) .addToData(KmlFactory.createData("4").withName("holePar")); {code} {card} {card:label=POJO example} {code:title=Listing ExtendedData Value(as POJOs). } final Placemark placemark = new Placemark(); placemark.setName("Club house"); final ExtendedData extendedData = new ExtendedData(); placemark.setExtendedData(extendedData); final Data data1 = new Data("1"); extendedData.getData().add(data1); data1.setName("holeNumber"); final Data data2 = new Data("4"); extendedData.getData().add(data2); data2.setName("holePar"); {code} {card} {card:label=KML output} {code:xml|title=Listing ExtendedDataValue.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Placemark xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <name>Club house</name> <ExtendedData> <Data name="holeNumber"> <value>1</value> </Data> <Data name="holePar"> <value>4</value> </Data> </ExtendedData> </Placemark> {code} {card} {deck} {deck:id=ExtendedData2} {card:label=Fluent example} {code:title=Listing ExtendedData-SimpleData (as fluent). } final Document document = KmlFactory.createDocument(); final Placemark placemark1 = document.createAndAddPlacemark().withName("Easy trail"); placemark1.createAndSetExtendedData() .addToSchemaData(new SchemaData().withSchemaUrl("#TrailHeadTypeId") .addToSimpleData(KmlFactory.createSimpleData("TrailHeadName").withValue("Pi in the sky")) .addToSimpleData(KmlFactory.createSimpleData("TrailLength").withValue("3.14159")) .addToSimpleData(KmlFactory.createSimpleData("ElevationGain").withValue("10")) ); placemark1.createAndSetPoint().createAndSetCoordinates().add(new Coordinate(-122.000,37.002)); final Placemark placemark2 = document.createAndAddPlacemark().withName("Difficult trail"); placemark2.createAndSetExtendedData() .addToSchemaData(new SchemaData().withSchemaUrl("#TrailHeadTypeId") .addToSimpleData(KmlFactory.createSimpleData("TrailHeadName").withValue("Mount Everest")) .addToSimpleData(KmlFactory.createSimpleData("TrailLength").withValue("347.45")) .addToSimpleData(KmlFactory.createSimpleData("ElevationGain").withValue("10000")) ); placemark2.createAndSetPoint().createAndSetCoordinates().add(new Coordinate(-122.000,37.002)); {code} {card} {card:label=POJO example} {code:title=Listing ExtendedData-SimpleData (as POJOs). } final Document document = new Document(); final Placemark placemark1 = new Placemark(); document.getFeature().add(placemark1); placemark1.setName("Easy trail"); final ExtendedData extendedData1 = new ExtendedData(); placemark1.setExtendedData(extendedData1); final SchemaData schemaData1 = new SchemaData(); schemaData1.setSchemaUrl("#TrailHeadTypeId"); extendedData1.getSchemaData().add(schemaData1); final SimpleData sd11 = new SimpleData("TrailHeadName"); sd11.setValue("Pi in the sky"); final SimpleData sd12 = new SimpleData("TrailLength"); sd12.setValue("3.14159"); final SimpleData sd13 = new SimpleData("ElevationGain"); sd13.setValue("10"); schemaData1.getSimpleData().add(sd11); schemaData1.getSimpleData().add(sd12); schemaData1.getSimpleData().add(sd13); final Point point1 = new Point(); placemark1.setGeometry(point1); List<Coordinate> coord1 = new ArrayList<Coordinate>(); point1.setCoordinates(coord1); coord1.add(new Coordinate(-122.000,37.002)); final Placemark placemark2 = new Placemark(); document.getFeature().add(placemark2); placemark2.setName("Difficult trail"); final ExtendedData extendedData2 = new ExtendedData(); placemark2.setExtendedData(extendedData2); final SchemaData schemaData2 = new SchemaData(); schemaData2.setSchemaUrl("#TrailHeadTypeId"); extendedData2.getSchemaData().add(schemaData2); final SimpleData sd21 = new SimpleData("TrailHeadName"); sd21.setValue("Mount Everest"); final SimpleData sd22 = new SimpleData("TrailLength"); sd22.setValue("347.45"); final SimpleData sd23 = new SimpleData("ElevationGain"); sd23.setValue("10000"); schemaData2.getSimpleData().add(sd21); schemaData2.getSimpleData().add(sd22); schemaData2.getSimpleData().add(sd23); final Point point2 = new Point(); placemark2.setGeometry(point2); List<Coordinate> coord2 = new ArrayList<Coordinate>(); point2.setCoordinates(coord2); coord2.add(new Coordinate(-122.000,37.002)); {code} {card} {card:label=KML output} {code:xml|title=Listing ExtendedData-SimpleData.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Document xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Placemark> <name>Easy trail</name> <ExtendedData> <SchemaData schemaUrl="#TrailHeadTypeId"> <SimpleData name="TrailHeadName">Pi in the sky</SimpleData> <SimpleData name="TrailLength">3.14159</SimpleData> <SimpleData name="ElevationGain">10</SimpleData> </SchemaData> </ExtendedData> <Point> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.0,37.002</coordinates> </Point> </Placemark> <Placemark> <name>Difficult trail</name> <ExtendedData> <SchemaData schemaUrl="#TrailHeadTypeId"> <SimpleData name="TrailHeadName">Mount Everest</SimpleData> <SimpleData name="TrailLength">347.45</SimpleData> <SimpleData name="ElevationGain">10000</SimpleData> </SchemaData> </ExtendedData> <Point> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.0,37.002</coordinates> </Point> </Placemark> </Document> {code} {card} {deck} h3. {{<Feature>}} Original example can be found here:[{{<Feature>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#feature] {deck:id=Feature} {card:label=Fluent example} {code:title=Listing Feature (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument(); document.createAndSetAtomAuthor().addToNameOrUriOrEmail("J. K. Rowling"); document.createAndSetAtomLink("http://www.harrypotter.com"); document.createAndAddPlacemark().withName("Hogwarts") .createAndSetPoint().createAndSetCoordinates().add(new Coordinate(1,1)); document.createAndAddPlacemark().withName("Little Hangleton") .createAndSetPoint().createAndSetCoordinates().add(new Coordinate(1,2)); {code} {card} {card:label=POJO example} {code:title=Listing Feature (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); kml.setFeature(document); final Author author = new Author(); document.setAtomAuthor(author); author.getNameOrUriOrEmail().add("J. K. Rowling"); final de.micromata.opengis.kml.v_2_2_0.atom.Link link = new de.micromata.opengis.kml.v_2_2_0.atom.Link("http://www.harrypotter.com"); document.setAtomLink(link); final Placemark placemark1 = new Placemark(); document.getFeature().add(placemark1); placemark1.setName("Hogwarts"); final Point point1 = new Point(); placemark1.setGeometry(point1); List<Coordinate> coord1 = new ArrayList<Coordinate>(); point1.setCoordinates(coord1); coord1.add(new Coordinate(1,1)); final Placemark placemark2 = new Placemark(); document.getFeature().add(placemark2); placemark2.setName("Little Hangleton"); final Point point2 = new Point(); placemark2.setGeometry(point2); List<Coordinate> coord2 = new ArrayList<Coordinate>(); point2.setCoordinates(coord2); coord2.add(new Coordinate(1,2)); {code} {card} {card:label=KML output} {code:xml|title=Listing Feature.kml. The output of the POJO and the fluent example.} {code} {card} {deck} h3. {{<Folder>}} Original example can be found here:[{{<Folder>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#folder] {deck:id=Folder} {card:label=Fluent example} {code:title=Listing Folder (as fluent). } final Kml kml = KmlFactory.createKml(); final Folder folder = kml.createAndSetFolder() .withName("Folder.kml") .withOpen(true) .withDescription("A folder is a container that can hold multiple other objects"); folder.createAndAddPlacemark().withName("Folder object 1 (Placemark)") .createAndSetPoint().addToCoordinates("-122.377588,37.830266,0"); folder.createAndAddPlacemark().withName("Folder object 2 (Polygon)") .createAndSetPolygon().createAndSetOuterBoundaryIs() .createAndSetLinearRing() .addToCoordinates("-122.377830,37.830445,0") .addToCoordinates("-122.377576,37.830631,0") .addToCoordinates("-122.377840,37.830642,0") .addToCoordinates("-122.377830,37.830445,0"); folder.createAndAddPlacemark().withName("Folder object 3 (Path)") .createAndSetLineString().withTessellate(true) .addToCoordinates("-122.378009,37.830128,0") .addToCoordinates("-122.377885,37.830379,0"); {code} {card} {card:label=POJO example} {code:title=Listing Folder (as POJOs). } final Kml kml = new Kml(); final Folder folder = new Folder(); kml.setFeature(folder); folder.setName("Folder.kml"); folder.setOpen(true); folder.setDescription("A folder is a container that can hold multiple other objects"); final Placemark placemark1 = new Placemark(); folder.getFeature().add(placemark1); placemark1.setName("Folder object 1 (Placemark)"); final Point point1 = new Point(); placemark1.setGeometry(point1); List<Coordinate> coord1 = new ArrayList<Coordinate>(); point1.setCoordinates(coord1); coord1.add(new Coordinate(-122.377588,37.830266,0)); final Placemark placemark2 = new Placemark(); folder.getFeature().add(placemark2); placemark2.setName("Folder object 2 (Polygon)"); final Polygon polygon = new Polygon(); placemark2.setGeometry(polygon); final Boundary boundary = new Boundary(); polygon.setOuterBoundaryIs(boundary); final LinearRing linearRing = new LinearRing(); boundary.setLinearRing(linearRing); List<Coordinate> coord2 = new ArrayList<Coordinate>(); linearRing.setCoordinates(coord2); coord2.add(new Coordinate(-122.377830,37.830445,0)); coord2.add(new Coordinate(-122.377576,37.830631,0)); coord2.add(new Coordinate(-122.377840,37.830642,0)); coord2.add(new Coordinate(-122.377830,37.830445,0)); final Placemark placemark3 = new Placemark(); folder.getFeature().add(placemark3); placemark3.setName("Folder object 3 (Path)"); final LineString lineString = new LineString(); placemark3.setGeometry(lineString); lineString.setTessellate(true); List<Coordinate> coord3 = new ArrayList<Coordinate>(); lineString.setCoordinates(coord3); coord3.add(new Coordinate(-122.378009,37.830128,0)); coord3.add(new Coordinate(-122.377885,37.830379,0)); {code} {card} {card:label=KML output} {code:xml|title=Listing Folder.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Folder> <name>Folder.kml</name> <open>true</open> <description>A folder is a container that can hold multiple other objects</description> <Placemark> <name>Folder object 1 (Placemark)</name> <Point> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.377588,37.830266</coordinates> </Point> </Placemark> <Placemark> <name>Folder object 2 (Polygon)</name> <Polygon> <altitudeMode>clampToGround</altitudeMode> <outerBoundaryIs> <LinearRing> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.37783,37.830445 -122.377576,37.830631 -122.37784,37.830642 -122.37783,37.830445</coordinates> </LinearRing> </outerBoundaryIs> </Polygon> </Placemark> <Placemark> <name>Folder object 3 (Path)</name> <LineString> <tessellate>true</tessellate> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.378009,37.830128 -122.377885,37.830379</coordinates> </LineString> </Placemark> </Folder> </kml> {code} {card} {deck} h3. {{<GroundOverlay>}} Original example can be found here:[{{<GroundOverlay>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#groundoverlay] {deck:id=GroundOverlay} {card:label=Fluent example} {code:title=Listing GroundOverlay (as fluent). } final Kml kml = KmlFactory.createKml(); final GroundOverlay groundoverlay = kml.createAndSetGroundOverlay() .withName("GroundOverlay.kml") .withColor("7fffffff") .withDrawOrder(1); groundoverlay.createAndSetIcon() .withHref("http://www.google.com/intl/en/images/logo.gif") .withRefreshMode(RefreshMode.ON_INTERVAL) .withRefreshInterval(86400d) .withViewBoundScale(0.75d); groundoverlay.createAndSetLatLonBox() .withNorth(37.83234d) .withSouth(37.832122d) .withEast(-122.373033d) .withWest(-122.373724d) .withRotation(45d); {code} {card} {card:label=POJO example} {code:title=Listing GroundOverlay (as POJOs). } final Kml kml = new Kml(); final GroundOverlay groundoverlay = new GroundOverlay(); kml.setFeature(groundoverlay); groundoverlay.setName("GroundOverlay.kml"); groundoverlay.setColor("7fffffff"); groundoverlay.setDrawOrder(1); final Icon icon = new Icon(); groundoverlay.setIcon(icon); icon.setHref("http://www.google.com/intl/en/images/logo.gif"); icon.setRefreshMode(RefreshMode.ON_INTERVAL); icon.setRefreshInterval(86400d); icon.setViewBoundScale(0.75d); final LatLonBox latlonBox = new LatLonBox(); groundoverlay.setLatLonBox(latlonBox); latlonBox.setNorth(37.83234d); latlonBox.setSouth(37.832122d); latlonBox.setEast(-122.373033d); latlonBox.setWest(-122.373724d); latlonBox.setRotation(45d); {code} {card} {card:label=KML output} {code:xml|title=Listing GroundOverlay.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <GroundOverlay> <name>GroundOverlay.kml</name> <color>7fffffff</color> <drawOrder>1</drawOrder> <Icon> <href>http://www.google.com/intl/en/images/logo.gif</href> <refreshMode>onInterval</refreshMode> <refreshInterval>86400.0</refreshInterval> <viewRefreshTime>0.0</viewRefreshTime> <viewBoundScale>0.75</viewBoundScale> </Icon> <altitude>0.0</altitude> <altitudeMode>clampToGround</altitudeMode> <LatLonBox> <north>37.83234</north> <south>37.832122</south> <east>-122.373033</east> <west>-122.373724</west> <rotation>45.0</rotation> </LatLonBox> </GroundOverlay> </kml> {code} {card} {deck} h3. {{<Icon>}} Original example can be found here:[{{<Icon>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#icon] {deck:id=Icon} {card:label=Fluent example} {code:title=Listing Icon (as fluent). } final Icon icon = (Icon) new Icon() .withHref("...") .withRefreshMode(RefreshMode.ON_CHANGE) .withRefreshInterval(4d) .withViewRefreshMode(ViewRefreshMode.NEVER) .withViewRefreshTime(4d) .withViewBoundScale(1d) .withHttpQuery("..."); {code} {card} {card:label=POJO example} {code:title=Listing Icon (as POJOs). } final Icon icon = new Icon(); icon.setHref("..."); icon.setRefreshMode(RefreshMode.ON_CHANGE); icon.setRefreshInterval(4d); icon.setViewRefreshMode(ViewRefreshMode.NEVER); icon.setViewRefreshTime(4d); icon.setViewBoundScale(1d); icon.setHttpQuery("..."); {code} {card} {card:label=KML output} {code:xml|title=Listing Icon.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <IconStyle xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.google.com/kml/ext/2.2" xmlns:ns3="http://www.w3.org/2005/Atom" xmlns:ns4="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"> <color>ffffffff</color> <colorMode>normal</colorMode> <scale>1.0</scale> <heading>0.0</heading> <Icon> <href>...</href> <refreshInterval>0.0</refreshInterval> <viewRefreshTime>0.0</viewRefreshTime> <viewBoundScale>0.0</viewBoundScale> </Icon> <hotSpot yunits="fraction" xunits="fraction" y="0.5" x="0.5"/> </IconStyle> {code} {card} {deck} h3. {{<IconStyle>}} Original example can be found here:[{{<IconStyle>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#iconstyle] {deck:id=IconStyle} {card:label=Fluent example} {code:title=Listing IconStyle (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument(); final Style style = document.createAndAddStyle().withId("randomColorIcon"); final IconStyle iconstyle = style.createAndSetIconStyle() .withColor("ff00ff00") .withColorMode(ColorMode.RANDOM) .withScale(1.1d); iconstyle.createAndSetIcon().withHref("http://maps.google.com/mapfiles/kml/pal3/icon21.png"); document.createAndAddPlacemark().withName("IconStyle.kml").withStyleUrl("#randomColorIcon") .createAndSetPoint().addToCoordinates("-122.36868,37.831145,0"); {code} {card} {card:label=POJO example} {code:title=Listing IconStyle (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); kml.setFeature(document); final Style style = new Style(); document.getStyleSelector().add(style); style.setId("randomColorIcon"); final IconStyle iconstyle = new IconStyle(); style.setIconStyle(iconstyle); iconstyle.setColor("ff00ff00"); iconstyle.setColorMode(ColorMode.RANDOM); iconstyle.setScale(1.1d); final Icon icon = new Icon(); iconstyle.setIcon(icon); icon.setHref("http://maps.google.com/mapfiles/kml/pal3/icon21.png"); final Placemark placemark = new Placemark(); document.getFeature().add(placemark); placemark.setName("IconStyle.kml"); placemark.setStyleUrl("#randomColorIcon"); final Point point = new Point(); placemark.setGeometry(point); List<Coordinate> coord = new ArrayList<Coordinate>(); point.setCoordinates(coord); coord.add(new Coordinate(-122.36868,37.831145,0)); {code} {card} {card:label=KML output} {code:xml|title=Listing IconStyle.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Document> <Style id="randomColorIcon"> <IconStyle> <color>ff00ff00</color> <colorMode>random</colorMode> <scale>1.1</scale> <heading>0.0</heading> <Icon> <href>http://maps.google.com/mapfiles/kml/pal3/icon21.png</href> <refreshInterval>0.0</refreshInterval> <viewRefreshTime>0.0</viewRefreshTime> <viewBoundScale>0.0</viewBoundScale> </Icon> </IconStyle> </Style> <Placemark> <name>IconStyle.kml</name> <styleUrl>#randomColorIcon</styleUrl> <Point> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.36868,37.831145</coordinates> </Point> </Placemark> </Document> </kml> {code} {card} {deck} h3. {{<kml>}} Original example can be found here:[{{<kml>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#kml] {deck:id=kml} {card:label=Fluent example} {code:title=Listing kml (as fluent). } final Kml kml = KmlFactory.createKml().withHint("sky"); {code} {card} {card:label=POJO example} {code:title=Listing kml (as POJOs). } final Kml kml = new Kml(); kml.setHint("sky"); {code} {card} {card:label=KML output} {code:xml|title=Listing kml.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2" hint="sky"/> {code} {card} {deck} h3. {{<LabelStyle>}} Original example can be found here:[{{<LabelStyle>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#labelstyle] {deck:id=LabelStyle} {card:label=Fluent example} {code:title=Listing LabelStyle (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument(); final Style style = document.createAndAddStyle().withId("randomLabelColor"); final LabelStyle labelstyle = style.createAndSetLabelStyle() .withColor("ff0000cc") .withColorMode(ColorMode.RANDOM) .withScale(1.5d); document.createAndAddPlacemark().withName("LabelStyle.kml").withStyleUrl("#randomLabelColor") .createAndSetPoint().addToCoordinates("-122.367375,37.829192,0"); {code} {card} {card:label=POJO example} {code:title=Listing LabelStyle (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); kml.setFeature(document); final Style style = new Style(); document.getStyleSelector().add(style); style.setId("randomLabelColor"); final LabelStyle labelstyle = new LabelStyle(); style.setLabelStyle(labelstyle); labelstyle.setColor("ff0000cc"); labelstyle.setColorMode(ColorMode.RANDOM); labelstyle.setScale(1.5d); final Placemark placemark = new Placemark(); document.getFeature().add(placemark); placemark.setName("LabelStyle.kml"); placemark.setStyleUrl("#randomLabelColor"); final Point point = new Point(); placemark.setGeometry(point); List<Coordinate> coord = new ArrayList<Coordinate>(); point.setCoordinates(coord); coord.add(new Coordinate(-122.367375,37.829192,0)); {code} {card} {card:label=KML output} {code:xml|title=Listing LabelStyle.kml. The output of the POJO and the fluent example.} {code} {card} {deck} h3. {{<LinearRing>}} Original example can be found here:[{{<LinearRing>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#linearring] {deck:id=LinearRing} {card:label=Fluent example} {code:title=Listing LinearRing (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument(); document.createAndAddPlacemark().withName("LinearRing.kml") .createAndSetPolygon().createAndSetOuterBoundaryIs().createAndSetLinearRing() .addToCoordinates(-122.365662,37.826988,0) .addToCoordinates(-122.365202,37.826302,0) .addToCoordinates(-122.364581,37.82655,0) .addToCoordinates(-122.365038,37.827237,0) .addToCoordinates(-122.365662,37.826988,0); {code} {card} {card:label=POJO example} {code:title=Listing LinearRing (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); kml.setFeature(document); final Placemark placemark = new Placemark(); document.getFeature().add(placemark); placemark.setName("LinearRing.kml"); final Polygon polygon = new Polygon(); placemark.setGeometry(polygon); final Boundary boundary = new Boundary(); polygon.setOuterBoundaryIs(boundary); final LinearRing linearring = new LinearRing(); boundary.setLinearRing(linearring); List<Coordinate> coord = new ArrayList<Coordinate>(); linearring.setCoordinates(coord); coord.add(new Coordinate(-122.365662,37.826988,0)); coord.add(new Coordinate(-122.365202,37.826302,0)); coord.add(new Coordinate(-122.364581,37.82655,0)); coord.add(new Coordinate(-122.365038,37.827237,0)); coord.add(new Coordinate(-122.365662,37.826988,0)); {code} {card} {card:label=KML output} {code:xml|title=Listing LinearRing.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Document> <Placemark> <name>LinearRing.kml</name> <Polygon> <altitudeMode>clampToGround</altitudeMode> <outerBoundaryIs> <LinearRing> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.365662,37.826988 -122.365202,37.826302 -122.364581,37.82655 -122.365038,37.827237 -122.365662,37.826988</coordinates> </LinearRing> </outerBoundaryIs> </Polygon> </Placemark> </Document> </kml> {code} {card} {deck} h3. {{<LineString>}} Original example can be found here:[{{<LineString>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#linestring] {deck:id=LineString} {card:label=Fluent example} {code:title=Listing LineString (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument().withName("LineString.kml").withOpen(true); final LookAt lookat = document.createAndSetLookAt() .withLongitude(-122.36415) .withLatitude(37.824553) .withRange(150.0d) .withTilt(50.0d) .withHeading(0.0d); document.createAndAddPlacemark().withName("unextruded") .createAndSetLineString().withExtrude(false).withTessellate(true) .addToCoordinates("-122.364383,37.824664,0") .addToCoordinates("-122.364152,37.824322,0"); document.createAndAddPlacemark().withName("extruded") .createAndSetLineString().withExtrude(true).withTessellate(true) .addToCoordinates("-122.364167,37.824787,50") .addToCoordinates("-122.363917,37.824423,50"); {code} {card} {card:label=POJO example} {code:title=Listing LineString (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); kml.setFeature(document); document.setName("LineString.kml"); document.setOpen(true); final LookAt lookat = new LookAt(); lookat.setLongitude(-122.36415); lookat.setLatitude(37.824553); lookat.setRange(150.0d); lookat.setTilt(50.0d); lookat.setHeading(0.0d); document.setAbstractView(lookat); final Placemark placemark1 = new Placemark(); document.getFeature().add(placemark1); placemark1.setName("unextruded"); final LineString linestring1 = new LineString(); placemark1.setGeometry(linestring1); linestring1.setExtrude(false); linestring1.setTessellate(true); List<Coordinate> coord1 = new ArrayList<Coordinate>(); linestring1.setCoordinates(coord1); coord1.add(new Coordinate(-122.364383,37.824664,0)); coord1.add(new Coordinate(-122.364152,37.824322,0)); final Placemark placemark2 = new Placemark(); document.getFeature().add(placemark2); placemark2.setName("extruded"); final LineString linestring2 = new LineString(); placemark2.setGeometry(linestring2); linestring2.setExtrude(true); linestring2.setTessellate(true); List<Coordinate> coord2 = new ArrayList<Coordinate>(); linestring2.setCoordinates(coord2); coord2.add(new Coordinate(-122.364167,37.824787,50)); coord2.add(new Coordinate(-122.363917,37.824423,50)); {code} {card} {card:label=KML output} {code:xml|title=Listing LineString.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Document> <name>LineString.kml</name> <open>true</open> <LookAt> <longitude>-122.36415</longitude> <latitude>37.824553</latitude> <altitude>0.0</altitude> <heading>0.0</heading> <tilt>50.0</tilt> <range>150.0</range> <altitudeMode>clampToGround</altitudeMode> </LookAt> <Placemark> <name>unextruded</name> <LineString> <extrude>false</extrude> <tessellate>true</tessellate> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.364383,37.824664 -122.364152,37.824322</coordinates> </LineString> </Placemark> <Placemark> <name>extruded</name> <LineString> <extrude>true</extrude> <tessellate>true</tessellate> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.364167,37.824787,50.0 -122.363917,37.824423,50.0</coordinates> </LineString> </Placemark> </Document> </kml> {code} {card} {deck} h3. {{<LineStyle>}} Original example can be found here:[{{<LineStyle>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#linestyle] {deck:id=LineStyle} {card:label=Fluent example} {code:title=Listing LineStyle (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument().withName("LineStyle.kml").withOpen(true); final Style style = document.createAndAddStyle().withId("linestyleExample"); style.createAndSetLineStyle() .withColor("7f0000ff") .withWidth(4.0d); document.createAndAddPlacemark().withName("LineStyle Example").withStyleUrl("#linestyleExample") .createAndSetLineString().withExtrude(true).withTessellate(true) .addToCoordinates("-122.364383,37.824664,0") .addToCoordinates("-122.364152,37.824322,0"); {code} {card} {card:label=POJO example} {code:title=Listing LineStyle (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); kml.setFeature(document); document.setName("LineStyle.kml"); document.setOpen(true); final Style style = new Style(); document.getStyleSelector().add(style); style.setId("linestyleExample"); final LineStyle linestyle = new LineStyle(); style.setLineStyle(linestyle); linestyle.setColor("7f0000ff"); linestyle.setWidth(4.0d); final Placemark placemark = new Placemark(); document.getFeature().add(placemark); placemark.setName("LineStyle Example"); placemark.setStyleUrl("#linestyleExample"); final LineString linestring = new LineString(); placemark.setGeometry(linestring); linestring.setExtrude(true); linestring.setTessellate(true); List<Coordinate> coord1 = new ArrayList<Coordinate>(); linestring.setCoordinates(coord1); coord1.add(new Coordinate(-122.364383,37.824664,0)); coord1.add(new Coordinate(-122.364152,37.824322,0)); {code} {card} {card:label=KML output} {code:xml|title=Listing LineStyle.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Document> <name>LineStyle.kml</name> <open>true</open> <Style id="linestyleExample"> <LineStyle> <color>7f0000ff</color> <width>4.0</width> </LineStyle> </Style> <Placemark> <name>LineStyle Example</name> <styleUrl>#linestyleExample</styleUrl> <LineString> <extrude>true</extrude> <tessellate>true</tessellate> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.364383,37.824664 -122.364152,37.824322</coordinates> </LineString> </Placemark> </Document> </kml> {code} {card} {deck} h3. {{<Link>}} Original example can be found here:[{{<Link>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#link] {deck:id=Link} {card:label=Fluent example} {code:title=Listing Link (as fluent). } final NetworkLink networklink = KmlFactory.createNetworkLink() .withName("NE US Radar") .withFlyToView(true); networklink.createAndSetLink() .withHref("http://www.example.com/geotiff/NE/MergedReflectivityQComposite.kml") .withRefreshMode(RefreshMode.ON_INTERVAL) .withRefreshInterval(30.0d) .withViewRefreshMode(ViewRefreshMode.ON_STOP) .withViewRefreshTime(7.0d) .withViewFormat("BBOX=bboxWest") .withHttpQuery("..."); {code} {card} {card:label=POJO example} {code:title=Listing Link (as POJOs). } final NetworkLink networklink = new NetworkLink(); networklink.setName("NE US Radar"); networklink.setFlyToView(true); final Link link = new Link(); networklink.setLink(link); link.setHref("http://www.example.com/geotiff/NE/MergedReflectivityQComposite.kml"); link.setRefreshMode(RefreshMode.ON_INTERVAL); link.setRefreshInterval(30.0d); link.setViewRefreshMode(ViewRefreshMode.ON_STOP); link.setViewRefreshTime(7.0d); link.setViewFormat("BBOX=bboxWest"); link.setHttpQuery("..."); {code} {card} {card:label=KML output} {code:xml|title=Listing Link.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <NetworkLink xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <name>NE US Radar</name> <flyToView>true</flyToView> <Link> <href>http://www.example.com/geotiff/NE/MergedReflectivityQComposite.kml</href> <refreshMode>onInterval</refreshMode> <refreshInterval>30.0</refreshInterval> <viewRefreshMode>onStop</viewRefreshMode> <viewRefreshTime>7.0</viewRefreshTime> <viewBoundScale>0.0</viewBoundScale> <viewFormat>BBOX=bboxWest</viewFormat> <httpQuery>...</httpQuery> </Link> </NetworkLink> {code} {card} {deck} h3. {{<ListStyle>}} Original example can be found here:[{{<ListStyle>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#liststyle] {deck:id=ListStyle} {card:label=Fluent example} {code:title=Listing ListStyle (as fluent). } final ListStyle liststyle = KmlFactory.createListStyle() .withId("ID") // <!-- specific to ListStyle --> .withListItemType(ListItemType.CHECK) .withBgColor("ffffffff"); liststyle.createAndAddItemIcon().addToState(ItemIconState.OPEN).withHref("..."); {code} {card} {card:label=POJO example} {code:title=Listing ListStyle (as POJOs). } final ListStyle liststyle = new ListStyle(); liststyle.setId("ID"); // <!-- specific to ListStyle --> liststyle.setListItemType(ListItemType.CHECK); liststyle.setBgColor("ffffffff"); final ItemIcon itemicon = new ItemIcon(); liststyle.getItemIcon().add(itemicon); itemicon.getState().add(ItemIconState.OPEN); itemicon.setHref("..."); {code} {card} {card:label=KML output} {code:xml|title=Listing ListStyle.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <ListStyle xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.google.com/kml/ext/2.2" xmlns:ns3="http://www.w3.org/2005/Atom" xmlns:ns4="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" id="ID"> <listItemType>check</listItemType> <bgColor>ffffffff</bgColor> <ItemIcon> <state>open</state> <href>...</href> </ItemIcon> <maxSnippetLines>0</maxSnippetLines> </ListStyle> {code} {card} {deck} h3. {{<LookAt>}} Original example can be found here:[{{<LookAt>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#lookat] {deck:id=LookAt} {card:label=Fluent example} {code:title=Listing LookAt (as fluent). } final Kml kml = KmlFactory.createKml(); final Placemark placemark = kml.createAndSetPlacemark().withName("LookAt.kml"); placemark.createAndSetLookAt() .withLongitude(-122.363) .withLatitude(37.81) .withAltitude(2000.0d) .withRange(500.0) .withTilt(45.0) .withHeading(0.0) .withAltitudeMode(AltitudeMode.RELATIVE_TO_GROUND); placemark.createAndSetPoint().addToCoordinates("-122.363,37.82,0"); {code} {card} {card:label=POJO example} {code:title=Listing LookAt (as POJOs). } final Kml kml = new Kml(); final Placemark placemark = new Placemark(); kml.setFeature(placemark); placemark.setName("LookAt.kml"); final LookAt lookat = new LookAt(); placemark.setAbstractView(lookat); lookat.setLongitude(-122.363); lookat.setLatitude(37.81); lookat.setAltitude(2000.0d); lookat.setRange(500.0); lookat.setTilt(45.0); lookat.setHeading(0.0); lookat.setAltitudeMode(AltitudeMode.RELATIVE_TO_GROUND); final Point point = new Point(); placemark.setGeometry(point); List<Coordinate> coord = new ArrayList<Coordinate>(); point.setCoordinates(coord); coord.add(new Coordinate(-122.363,37.82,0)); {code} {card} {card:label=KML output} {code:xml|title=Listing LookAt.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Placemark> <name>LookAt.kml</name> <LookAt> <longitude>-122.363</longitude> <latitude>37.81</latitude> <altitude>2000.0</altitude> <heading>0.0</heading> <tilt>45.0</tilt> <range>500.0</range> <altitudeMode>relativeToGround</altitudeMode> </LookAt> <Point> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.363,37.82</coordinates> </Point> </Placemark> </kml> {code} {card} {deck} h3. {{<Model>}} Original example can be found here:[{{<Model>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#model] {deck:id=Model} {card:label=Fluent example} {code:title=Listing Model (as fluent). } final Model model = KmlFactory.createModel() .withId("khModel543") .withAltitudeMode(AltitudeMode.RELATIVE_TO_GROUND); model.createAndSetLocation().withLongitude(39.55375305703105).withLatitude(-118.9813220168456).withAltitude(1223.0); model.createAndSetOrientation().withHeading(45.0).withTilt(10.0).withRoll(0.0); model.createAndSetScale().withX(1.0).withY(1.0).withZ(1.0); model.createAndSetLink().withHref("house.dae").withRefreshMode(RefreshMode.ON_CHANGE); final ResourceMap resourcemap = model.createAndSetResourceMap(); resourcemap.createAndAddAlias() .withTargetHref("../files/CU-Macky---Center-StairsnoCulling.jpg") .withSourceHref("CU-Macky---Center-StairsnoCulling.jpg"); resourcemap.createAndAddAlias() .withTargetHref("../files/CU-Macky-4sideturretnoCulling.jpg") .withSourceHref("CU-Macky-4sideturretnoCulling.jpg"); resourcemap.createAndAddAlias() .withTargetHref("../files/CU-Macky-Back-NorthnoCulling.jpg") .withSourceHref("CU-Macky-Back-NorthnoCulling.jpg"); {code} {card} {card:label=POJO example} {code:title=Listing Model (as POJOs). } final Model model = new Model(); model.setId("khModel543"); model.setAltitudeMode(AltitudeMode.RELATIVE_TO_GROUND); final Location location = new Location(); model.setLocation(location); location.setLongitude(39.55375305703105); location.setLatitude(-118.9813220168456); location.setAltitude(1223.0); final Orientation orientation = new Orientation(); model.setOrientation(orientation); orientation.setHeading(45.0); orientation.setTilt(10.0); orientation.setRoll(0.0); final Scale scale = new Scale(); model.setScale(scale); scale.setX(1.0); scale.setY(1.0); scale.setZ(1.0); final Link link = new Link(); model.setLink(link); link.setHref("house.dae"); link.setRefreshMode(RefreshMode.ON_CHANGE); final ResourceMap resourcemap = new ResourceMap(); model.setResourceMap(resourcemap); final Alias alias1 = new Alias(); resourcemap.getAlias().add(alias1); alias1.setTargetHref("../files/CU-Macky---Center-StairsnoCulling.jpg"); alias1.setSourceHref("CU-Macky---Center-StairsnoCulling.jpg"); final Alias alias2 = new Alias(); resourcemap.getAlias().add(alias2); alias2.setTargetHref("../files/CU-Macky-4sideturretnoCulling.jpg"); alias2.setSourceHref("CU-Macky-4sideturretnoCulling.jpg"); final Alias alias3 = new Alias(); resourcemap.getAlias().add(alias3); alias3.setTargetHref("../files/CU-Macky-Back-NorthnoCulling.jpg"); alias3.setSourceHref("CU-Macky-Back-NorthnoCulling.jpg"); {code} {card} {card:label=KML output} {code:xml|title=Listing Model.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Model xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.google.com/kml/ext/2.2" xmlns:ns3="http://www.w3.org/2005/Atom" xmlns:ns4="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" id="khModel543"> <altitudeMode>relativeToGround</altitudeMode> <Location> <longitude>39.55375305703105</longitude> <latitude>-118.9813220168456</latitude> <altitude>1223.0</altitude> </Location> <Orientation> <heading>45.0</heading> <tilt>10.0</tilt> <roll>0.0</roll> </Orientation> <Scale> <x>1.0</x> <y>1.0</y> <z>1.0</z> </Scale> <Link> <href>house.dae</href> <refreshMode>onChange</refreshMode> <refreshInterval>0.0</refreshInterval> <viewRefreshTime>0.0</viewRefreshTime> <viewBoundScale>0.0</viewBoundScale> </Link> <ResourceMap> <Alias> <targetHref>../files/CU-Macky---Center-StairsnoCulling.jpg</targetHref> <sourceHref>CU-Macky---Center-StairsnoCulling.jpg</sourceHref> </Alias> <Alias> <targetHref>../files/CU-Macky-4sideturretnoCulling.jpg</targetHref> <sourceHref>CU-Macky-4sideturretnoCulling.jpg</sourceHref> </Alias> <Alias> <targetHref>../files/CU-Macky-Back-NorthnoCulling.jpg</targetHref> <sourceHref>CU-Macky-Back-NorthnoCulling.jpg</sourceHref> </Alias> </ResourceMap> </Model> {code} {card} {deck} h3. {{<MultiGeometry>}} Original example can be found here:[{{<MultiGeometry>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#multigeometry] {deck:id=MultiGeometry} {card:label=Fluent example} {code:title=Listing MultiGeometry (as fluent). } final Placemark placemark = KmlFactory.createPlacemark() .withName("SF Marina Harbor Master") .withVisibility(false); final MultiGeometry multigeometry = placemark.createAndSetMultiGeometry(); multigeometry.createAndAddLineString() .addToCoordinates("-122.4425587930444,37.80666418607323,0") .addToCoordinates("-122.4428379594768,37.80663578323093,0"); multigeometry.createAndAddLineString() .addToCoordinates("-122.4425509770566,37.80662588061205,0") .addToCoordinates("-122.4428340530617,37.8065999493009,0"); {code} {card} {card:label=POJO example} {code:title=Listing MultiGeometry (as POJOs). } final Placemark placemark = new Placemark(); placemark.setName("SF Marina Harbor Master"); placemark.setVisibility(false); final MultiGeometry multigeometry = new MultiGeometry(); placemark.setGeometry(multigeometry); final LineString linestring1 = new LineString(); multigeometry.getGeometry().add(linestring1); List<Coordinate> coord1 = new ArrayList<Coordinate>(); linestring1.setCoordinates(coord1); coord1.add(new Coordinate(-122.4425587930444,37.80666418607323,0)); coord1.add(new Coordinate(-122.4428379594768,37.80663578323093,0)); final LineString linestring2 = new LineString(); multigeometry.getGeometry().add(linestring2); List<Coordinate> coord2 = new ArrayList<Coordinate>(); linestring2.setCoordinates(coord2); coord2.add(new Coordinate(-122.4425509770566,37.80662588061205,0)); coord2.add(new Coordinate(-122.4428340530617,37.8065999493009,0)); {code} {card} {card:label=KML output} {code:xml|title=Listing MultiGeometry.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Placemark xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <name>SF Marina Harbor Master</name> <visibility>false</visibility> <MultiGeometry> <LineString> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.4425587930444,37.80666418607323 -122.4428379594768,37.80663578323093</coordinates> </LineString> <LineString> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.4425509770566,37.80662588061205 -122.4428340530617,37.8065999493009</coordinates> </LineString> </MultiGeometry> </Placemark> {code} {card} {deck} h3. {{<NetworkLink>}} Original example can be found here:[{{<NetworkLink>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#networklink] {deck:id=NetworkLink} {card:label=Fluent example} {code:title=Listing NetworkLink (as fluent). } final Document document = KmlFactory.createDocument().withVisibility(true); final NetworkLink networklink = document.createAndAddNetworkLink() .withName("NE US Radar").withRefreshVisibility(true).withFlyToView(true); networklink.createAndSetLink().withHref("..."); {code} {card} {card:label=POJO example} {code:title=Listing NetworkLink (as POJOs). } final Document document = new Document(); document.setVisibility(true); final NetworkLink networklink = new NetworkLink(); document.getFeature().add(networklink); networklink.setName("NE US Radar"); networklink.setRefreshVisibility(true); networklink.setFlyToView(true); final Link link = new Link(); link.setHref("..."); networklink.setLink(link); {code} {card} {card:label=KML output} {code:xml|title=Listing NetworkLink.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Document xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <visibility>true</visibility> <NetworkLink> <name>NE US Radar</name> <refreshVisibility>true</refreshVisibility> <flyToView>true</flyToView> <Link> <href>...</href> <refreshInterval>0.0</refreshInterval> <viewRefreshTime>0.0</viewRefreshTime> <viewBoundScale>0.0</viewBoundScale> </Link> </NetworkLink> </Document> {code} {card} {deck} h3. {{<NetworkLinkControl>}} Original example can be found here:[{{<NetworkLinkControl>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#networklinkcontrol] {deck:id=NetworkLinkControl} {card:label=Fluent example} {code:title=Listing NetworkLinkControl (as fluent). } final Kml kml = KmlFactory.createKml(); final NetworkLinkControl networklinkcontrol = kml.createAndSetNetworkLinkControl() .withMessage("This is a pop-up message. You will only see this once") .withCookie("cookie=sometext") .withLinkName("New KML features") .withLinkDescription("<![CDATA[KML now has new features available!]]>"); {code} {card} {card:label=POJO example} {code:title=Listing NetworkLinkControl (as POJOs). } final Kml kml = new Kml(); final NetworkLinkControl networklinkcontrol = new NetworkLinkControl(); kml.setNetworkLinkControl(networklinkcontrol); networklinkcontrol.setMessage("This is a pop-up message. You will only see this once"); networklinkcontrol.setCookie("cookie=sometext"); networklinkcontrol.setLinkName("New KML features"); networklinkcontrol.setLinkDescription("<![CDATA[KML now has new features available!]]>"); {code} {card} {card:label=KML output} {code:xml|title=Listing NetworkLinkControl.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <NetworkLinkControl> <minRefreshPeriod>0.0</minRefreshPeriod> <maxSessionLength>0.0</maxSessionLength> <cookie>cookie=sometext</cookie> <message>This is a pop-up message. You will only see this once</message> <linkName>New KML features</linkName> <linkDescription><![CDATA[KML now has new features available!]]></linkDescription> </NetworkLinkControl> </kml> {code} {card} {deck} h3. {{<PhotoOverlay>}} Original example can be found here:[{{<PhotoOverlay>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#photooverlay] {deck:id=PhotoOverlay} {card:label=Fluent example} {code:title=Listing PhotoOverlay (as fluent). } final PhotoOverlay photooverlay = KmlFactory.createPhotoOverlay() .withName("A simple non-pyramidal photo") .withDescription("High above the ocean") // <!-- Overlay elements --> .withIcon(new Icon().withHref("small-photo.jpg")) // <!-- PhotoOverlay elements --> .withShape(Shape.RECTANGLE) .withRotation(0.0); photooverlay.createAndSetViewVolume() .withNear(1000.0) .withLeftFov(-60.0) .withRightFov(60.0) .withBottomFov(-45.0) .withTopFov(45.0); photooverlay.createAndSetImagePyramid() .withTileSize(0) .withMaxWidth(0) .withMaxHeight(0) .withGridOrigin(GridOrigin.LOWER_LEFT); photooverlay.createAndSetPoint().addToCoordinates("1,1"); {code} {card} {card:label=POJO example} {code:title=Listing PhotoOverlay (as POJOs). } final PhotoOverlay photooverlay = new PhotoOverlay(); photooverlay.setId("ID"); // <!-- inherited from Feature element --> photooverlay.setName("..."); photooverlay.setVisibility(true); photooverlay.setOpen(false); photooverlay.setAtomAuthor(new Author()); photooverlay.setAtomLink(new de.micromata.opengis.kml.v_2_2_0.atom.Link("...")); photooverlay.setAddress("..."); photooverlay.setXalAddressDetails(createAddressDetails()); photooverlay.setPhoneNumber("..."); final Snippet snippet = new Snippet(); photooverlay.setSnippet(snippet); snippet.setMaxLines(2); snippet.setValue("..."); photooverlay.setDescription("..."); photooverlay.setAbstractView(new Camera()); photooverlay.setTimePrimitive(new TimeSpan()); photooverlay.setStyleUrl("..."); photooverlay.getStyleSelector().add(new Style()); photooverlay.setRegion(new Region()); photooverlay.setMetadata(new Metadata()); photooverlay.setExtendedData(new ExtendedData()); // <!-- inherited from Overlay element --> photooverlay.setColor("ffffffff"); photooverlay.setDrawOrder(0); final Icon icon = new Icon(); icon.setHref("..."); photooverlay.setIcon(icon); // <!-- specific to PhotoOverlay --> photooverlay.setRotation(0.0); final ViewVolume viewvolume = new ViewVolume(); photooverlay.setViewVolume(viewvolume); viewvolume.setLeftFov(0.0); viewvolume.setRightFov(0.0); viewvolume.setBottomFov(0.0); viewvolume.setTopFov(0.0); viewvolume.setNear(0.0); final ImagePyramid imagepyramid = new ImagePyramid(); photooverlay.setImagePyramid(imagepyramid); imagepyramid.setTileSize(0); imagepyramid.setMaxWidth(0); imagepyramid.setMaxHeight(0); imagepyramid.setGridOrigin(GridOrigin.LOWER_LEFT); final Point point = new Point(); photooverlay.setPoint(point); List<Coordinate> coord = new ArrayList<Coordinate>(); point.setCoordinates(coord); coord.add(new Coordinate(0.0,0.0,0.0)); photooverlay.setShape(Shape.RECTANGLE); {code} {card} {card:label=KML output} {code:xml|title=Listing PhotoOverlay.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <PhotoOverlay xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <name>A simple non-pyramidal photo</name> <description>High above the ocean</description> <drawOrder>0</drawOrder> <Icon> <href>small-photo.jpg</href> <refreshInterval>0.0</refreshInterval> <viewRefreshTime>0.0</viewRefreshTime> <viewBoundScale>0.0</viewBoundScale> </Icon> <rotation>0.0</rotation> <ViewVolume> <leftFov>-60.0</leftFov> <rightFov>60.0</rightFov> <bottomFov>-45.0</bottomFov> <topFov>45.0</topFov> <near>1000.0</near> </ViewVolume> <ImagePyramid> <tileSize>0</tileSize> <maxWidth>0</maxWidth> <maxHeight>0</maxHeight> <gridOrigin>lowerLeft</gridOrigin> </ImagePyramid> <Point> <altitudeMode>clampToGround</altitudeMode> <coordinates>1.0,1.0</coordinates> </Point> <shape>rectangle</shape> </PhotoOverlay> {code} {card} {deck} h3. {{<Placemark>}} Original example can be found here:[{{<Placemark>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#placemark] {deck:id=Placemark} {card:label=Fluent example} {code:title=Listing Placemark (as fluent). } Placemark placemark = new Placemark() .withName("Google Earth - New Placemark") .withDescription("Some Descriptive text."); placemark.createAndSetLookAt() .withLongitude(-90.86879847669974) .withLatitude(48.25330383601299) .withRange(440.8) .withTilt(8.3) .withHeading(2.7); placemark.createAndSetPoint() .addToCoordinates("-90.86948943473118,48.25450093195546,0"); {code} {card} {card:label=POJO example} {code:title=Listing Placemark (as POJOs). } final Placemark placemark = new Placemark(); placemark.setName("Google Earth - New Placemark"); placemark.setDescription("Some Descriptive text."); final LookAt lookat = new LookAt(); lookat.setLongitude(-90.86879847669974); lookat.setLatitude(48.25330383601299); lookat.setRange(440.8); lookat.setTilt(8.3); lookat.setHeading(2.7); placemark.setAbstractView(lookat); final Point point = new Point(); placemark.setGeometry(point); List<Coordinate> coord = new ArrayList<Coordinate>(); point.setCoordinates(coord); coord.add(new Coordinate(-90.86948943473118,48.25450093195546,0)); {code} {card} {card:label=KML output} {code:xml|title=Listing Placemark.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Placemark xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <name>Google Earth - New Placemark</name> <description>Some Descriptive text.</description> <LookAt> <longitude>-90.86879847669974</longitude> <latitude>48.25330383601299</latitude> <altitude>0.0</altitude> <heading>2.7</heading> <tilt>8.3</tilt> <range>440.8</range> <altitudeMode>clampToGround</altitudeMode> </LookAt> <Point> <altitudeMode>clampToGround</altitudeMode> <coordinates>-90.86948943473118,48.25450093195546</coordinates> </Point> </Placemark> {code} {card} {deck} h3. {{<Point>}} Original example can be found here:[{{<Point>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#point] {deck:id=Point} {card:label=Fluent example} {code:title=Listing Point (as fluent). } final Point point = KmlFactory.createPoint() .addToCoordinates("-90.86948943473118,48.25450093195546"); {code} {card} {card:label=POJO example} {code:title=Listing Point (as POJOs). } final Point point = new Point(); List<Coordinate> coord = new ArrayList<Coordinate>(); point.setCoordinates(coord); coord.add(new Coordinate(-90.86948943473118,48.25450093195546)); {code} {card} {card:label=KML output} {code:xml|title=Listing Point.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Point xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.google.com/kml/ext/2.2" xmlns:ns3="http://www.w3.org/2005/Atom" xmlns:ns4="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"> <altitudeMode>clampToGround</altitudeMode> <coordinates>-90.86948943473118,48.25450093195546</coordinates> </Point> {code} {card} {deck} h3. {{<Polygon>}} Original example can be found here:[{{<Polygon>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#polygon] {deck:id=Polygon} {card:label=Fluent example} {code:title=Listing Polygon (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument().withName("Polygon.kml").withOpen(false); Polygon polygon = document.createAndAddPlacemark().withName("hollow box").createAndSetPolygon().withExtrude(true).withAltitudeMode(AltitudeMode.RELATIVE_TO_GROUND); polygon.createAndSetOuterBoundaryIs().createAndSetLinearRing() .addToCoordinates(-122.366278,37.818844,30) .addToCoordinates(-122.365248,37.819267,30) .addToCoordinates(-122.365640,37.819861,30) .addToCoordinates(-122.366669,37.819429,30) .addToCoordinates(-122.366278,37.818844,30); polygon.createAndAddInnerBoundaryIs().createAndSetLinearRing() .addToCoordinates(-122.366212,37.818977,30) .addToCoordinates(-122.365424,37.819294,30) .addToCoordinates(-122.365704,37.819731,30) .addToCoordinates(-122.366488,37.819402,30) .addToCoordinates(-122.366212,37.818977,30); {code} {card} {card:label=POJO example} {code:title=Listing Polygon (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); kml.setFeature(document); document.setName("Polygon.kml"); document.setOpen(false); final Placemark placemark = new Placemark(); document.getFeature().add(placemark); placemark.setName("hollow box"); final Polygon polygon = new Polygon(); placemark.setGeometry(polygon); polygon.setExtrude(true); polygon.setAltitudeMode(AltitudeMode.RELATIVE_TO_GROUND); final Boundary outerboundary = new Boundary(); polygon.setOuterBoundaryIs(outerboundary); final LinearRing outerlinearring = new LinearRing(); outerboundary.setLinearRing(outerlinearring); List<Coordinate> outercoord = new ArrayList<Coordinate>(); outerlinearring.setCoordinates(outercoord); outercoord.add(new Coordinate(-122.366278,37.818844,30)); outercoord.add(new Coordinate(-122.365248,37.819267,30)); outercoord.add(new Coordinate(-122.365640,37.819861,30)); outercoord.add(new Coordinate(-122.366669,37.819429,30)); outercoord.add(new Coordinate(-122.366278,37.818844,30)); final Boundary innerboundary = new Boundary(); polygon.getInnerBoundaryIs().add(innerboundary); final LinearRing innerlinearring = new LinearRing(); innerboundary.setLinearRing(innerlinearring); List<Coordinate> innercoord = new ArrayList<Coordinate>(); innerlinearring.setCoordinates(innercoord); innercoord.add(new Coordinate(-122.366212,37.818977,30)); innercoord.add(new Coordinate(-122.365424,37.819294,30)); innercoord.add(new Coordinate(-122.365704,37.819731,30)); innercoord.add(new Coordinate(-122.366488,37.819402,30)); innercoord.add(new Coordinate(-122.366212,37.818977,30)); {code} {card} {card:label=KML output} {code:xml|title=Listing Polygon.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Document> <name>Polygon.kml</name> <open>false</open> <Placemark> <name>hollow box</name> <Polygon> <extrude>true</extrude> <altitudeMode>relativeToGround</altitudeMode> <outerBoundaryIs> <LinearRing> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.366278,37.818844,30.0 -122.365248,37.819267,30.0 -122.36564,37.819861,30.0 -122.366669,37.819429,30.0 -122.366278,37.818844,30.0</coordinates> </LinearRing> </outerBoundaryIs> <innerBoundaryIs> <LinearRing> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.366212,37.818977,30.0 -122.365424,37.819294,30.0 -122.365704,37.819731,30.0 -122.366488,37.819402,30.0 -122.366212,37.818977,30.0</coordinates> </LinearRing> </innerBoundaryIs> </Polygon> </Placemark> </Document> </kml> {code} {card} {deck} h3. {{<PolyStyle>}} Original example can be found here:[{{<PolyStyle>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#polystyle] {deck:id=PolyStyle} {card:label=Fluent example} {code:title=Listing PolyStyle (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument().withName("PolygonStyle.kml").withOpen(true); document.createAndAddStyle().withId("examplePolyStyle") .createAndSetPolyStyle().withColor("ff0000cc").withColorMode(ColorMode.RANDOM); final Placemark placemark = document.createAndAddPlacemark().withName("hollow box").withStyleUrl("#examplePolyStyle"); final Polygon polygon = placemark.createAndSetPolygon().withExtrude(true).withAltitudeMode(AltitudeMode.RELATIVE_TO_GROUND); polygon.createAndSetOuterBoundaryIs().createAndSetLinearRing() .addToCoordinates(-122.3662784465226,37.81884427772081,30) .addToCoordinates(-122.3652480684771,37.81926777010555,30) .addToCoordinates(-122.365640222455,37.81986126286519,30) .addToCoordinates(-122.36666937925,37.81942987753481,30) .addToCoordinates(-122.3662784465226,37.81884427772081,30); polygon.createAndAddInnerBoundaryIs().createAndSetLinearRing() .addToCoordinates("-122.366212593918,37.81897719083808,30") .addToCoordinates("-122.3654241733188,37.81929450992014,30") .addToCoordinates("-122.3657048517827,37.81973175302663,30") .addToCoordinates("-122.3664882465854,37.81940249291773,30") .addToCoordinates("-122.366212593918,37.81897719083808,30"); {code} {card} {card:label=POJO example} {code:title=Listing PolyStyle (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); kml.setFeature(document); document.setName("PolygonStyle.kml"); document.setOpen(true); final Style style = new Style(); document.getStyleSelector().add(style); style.setId("examplePolyStyle"); final PolyStyle polyStyle = new PolyStyle(); style.setPolyStyle(polyStyle); polyStyle.setColor("ff0000cc"); polyStyle.setColorMode(ColorMode.RANDOM); final Placemark placemark = new Placemark(); document.getFeature().add(placemark); placemark.setName("hollow box"); placemark.setStyleUrl("#examplePolyStyle"); final Polygon polygon = new Polygon(); placemark.setGeometry(polygon); polygon.setExtrude(true); polygon.setAltitudeMode(AltitudeMode.RELATIVE_TO_GROUND); final Boundary outerboundary = new Boundary(); polygon.setOuterBoundaryIs(outerboundary); final LinearRing outerlinearring = new LinearRing(); outerboundary.setLinearRing(outerlinearring); List<Coordinate> outercoord = new ArrayList<Coordinate>(); outerlinearring.setCoordinates(outercoord); outercoord.add(new Coordinate(-122.3662784465226,37.81884427772081,30)); outercoord.add(new Coordinate(-122.3652480684771,37.81926777010555,30)); outercoord.add(new Coordinate(-122.365640222455,37.81986126286519,30)); outercoord.add(new Coordinate(-122.36666937925,37.81942987753481,30)); outercoord.add(new Coordinate(-122.3662784465226,37.81884427772081,30)); final Boundary innerboundary = new Boundary(); polygon.getInnerBoundaryIs().add(innerboundary); final LinearRing innerlinearring = new LinearRing(); innerboundary.setLinearRing(innerlinearring); List<Coordinate> innercoord = new ArrayList<Coordinate>(); innerlinearring.setCoordinates(innercoord); innercoord.add(new Coordinate(-122.366212593918,37.81897719083808,30)); innercoord.add(new Coordinate(-122.3654241733188,37.81929450992014,30)); innercoord.add(new Coordinate(-122.3657048517827,37.81973175302663,30)); innercoord.add(new Coordinate(-122.3664882465854,37.81940249291773,30)); innercoord.add(new Coordinate(-122.366212593918,37.81897719083808,30)); {code} {card} {card:label=KML output} {code:xml|title=Listing PolyStyle.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Document> <name>PolygonStyle.kml</name> <open>true</open> <Style id="examplePolyStyle"> <PolyStyle> <color>ff0000cc</color> <colorMode>random</colorMode> </PolyStyle> </Style> <Placemark> <name>hollow box</name> <styleUrl>#examplePolyStyle</styleUrl> <Polygon> <extrude>true</extrude> <altitudeMode>relativeToGround</altitudeMode> <outerBoundaryIs> <LinearRing> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.3662784465226,37.81884427772081,30.0 -122.3652480684771,37.81926777010555,30.0 -122.365640222455,37.81986126286519,30.0 -122.36666937925,37.81942987753481,30.0 -122.3662784465226,37.81884427772081,30.0</coordinates> </LinearRing> </outerBoundaryIs> <innerBoundaryIs> <LinearRing> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.366212593918,37.81897719083808,30.0 -122.3654241733188,37.81929450992014,30.0 -122.3657048517827,37.81973175302663,30.0 -122.3664882465854,37.81940249291773,30.0 -122.366212593918,37.81897719083808,30.0</coordinates> </LinearRing> </innerBoundaryIs> </Polygon> </Placemark> </Document> </kml> {code} {card} {deck} h3. {{<Region>}} Original example can be found here:[{{<Region>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#region] {deck:id=Region} {card:label=Fluent example} {code:title=Listing Region (as fluent). } final Region region = KmlFactory.createRegion(); final LatLonAltBox latlonBox = region.createAndSetLatLonAltBox() .withNorth(50.625) .withSouth(45.0d) .withEast(28.125) .withWest(22.5) .withMinAltitude(10.0) .withMaxAltitude(50.0) .withAltitudeMode(AltitudeMode.CLAMP_TO_GROUND); final Lod lod = region.createAndSetLod() .withMinLodPixels(128.0) .withMaxLodPixels(1024.0) .withMinFadeExtent(128.0) .withMaxFadeExtent(128.0); {code} {card} {card:label=POJO example} {code:title=Listing Region (as POJOs). } final Region region = new Region(); final LatLonAltBox latlonBox = new LatLonAltBox(); region.setLatLonAltBox(latlonBox); latlonBox.setNorth(50.625); latlonBox.setSouth(45.0d); latlonBox.setEast(28.125); latlonBox.setWest(22.5); latlonBox.setMinAltitude(10.0); latlonBox.setMaxAltitude(50.0); latlonBox.setAltitudeMode(AltitudeMode.CLAMP_TO_GROUND); final Lod lod = new Lod(); region.setLod(lod); lod.setMinLodPixels(128.0); lod.setMaxLodPixels(1024.0); lod.setMinFadeExtent(128.0); lod.setMaxFadeExtent(128.0); {code} {card} {card:label=KML output} {code:xml|title=Listing Region.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <Region xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.google.com/kml/ext/2.2" xmlns:ns3="http://www.w3.org/2005/Atom" xmlns:ns4="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0"> <LatLonAltBox> <north>50.625</north> <south>45.0</south> <east>28.125</east> <west>22.5</west> <minAltitude>10.0</minAltitude> <maxAltitude>50.0</maxAltitude> <altitudeMode>clampToGround</altitudeMode> </LatLonAltBox> <Lod> <minLodPixels>128.0</minLodPixels> <maxLodPixels>1024.0</maxLodPixels> <minFadeExtent>128.0</minFadeExtent> <maxFadeExtent>128.0</maxFadeExtent> </Lod> </Region> {code} {card} {deck} h3. {{<Schema>}} Original example can be found here:[{{<Schema>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#schema] {deck:id=Schema} {card:label=Fluent example} {code:title=Listing Schema (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument(); final Schema schema = document.createAndAddSchema() .withName("TrailHeadType") .withId("TrailHeadTypeId"); schema.createAndAddSimpleField() .withType("string") .withName("TrailHeadName") .withDisplayName("<![CDATA[<b>Trail Head Name</b>]]>"); schema.createAndAddSimpleField() .withType("double") .withName("TrailLength") .withDisplayName("<![CDATA[<i>The length in miles</i>]]>"); schema.createAndAddSimpleField() .withType("int") .withName("ElevationGain") .withDisplayName("<![CDATA[<i>change in altitude</i>]]>"); {code} {card} {card:label=POJO example} {code:title=Listing Schema (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); kml.setFeature(document); final Schema schema = new Schema(); document.getSchema().add(schema); schema.setName("TrailHeadType"); schema.setId("TrailHeadTypeId"); final SimpleField s1 = new SimpleField(); schema.getSimpleField().add(s1); s1.setType("string"); s1.setName("TrailHeadName"); s1.setDisplayName("<![CDATA[<b>Trail Head Name</b>]]>"); final SimpleField s2 = new SimpleField(); schema.getSimpleField().add(s2); s2.setType("double"); s2.setName("TrailLength"); s2.setDisplayName("<![CDATA[<i>The length in miles</i>]]>"); final SimpleField s3 = new SimpleField(); schema.getSimpleField().add(s3); s3.setType("int"); s3.setName("ElevationGain"); s3.setDisplayName("<![CDATA[<i>change in altitude</i>]]>"); {code} {card} {card:label=KML output} {code:xml|title=Listing Schema.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Document> <Schema id="TrailHeadTypeId" name="TrailHeadType"> <SimpleField name="TrailHeadName" type="string"> <displayName><![CDATA[<b>Trail Head Name</b>]]></displayName> </SimpleField> <SimpleField name="TrailLength" type="double"> <displayName><![CDATA[<i>The length in miles</i>]]></displayName> </SimpleField> <SimpleField name="ElevationGain" type="int"> <displayName><![CDATA[<i>change in altitude</i>]]></displayName> </SimpleField> </Schema> </Document> </kml> {code} {card} {deck} h3. {{<Style>}} Original example can be found here:[{{<Style>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#style] {deck:id=Style} {card:label=Fluent example} {code:title=Listing Style (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument(); // <!-- Begin Style Definitions --> final Style style = document.createAndAddStyle().withId("myDefaultStyles"); style.createAndSetIconStyle().withColor("a1ff00ff").withScale(1.399999976158142).withIcon(new Icon().withHref("http://myserver.com/icon.jpg")); style.createAndSetLabelStyle().withColor("7fffaaff").withScale(1.5); style.createAndSetLineStyle().withColor("ff0000ff").withWidth(15.0); style.createAndSetPolyStyle().withColor("7f7faaaa").withColorMode(ColorMode.RANDOM); // <!-- Placemark #1 --> document.createAndAddPlacemark() .withName("Google Earth - New Polygon") .withDescription("Here is some descriptive text") .withStyleUrl("#myDefaultStyles"); // <!-- Placemark #2 --> document.createAndAddPlacemark() .withName("Google Earth - New Path") .withStyleUrl("#myDefaultStyles"); {code} {card} {card:label=POJO example} {code:title=Listing Style (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); kml.setFeature(document); // <!-- Begin Style Definitions --> final Style style = new Style(); style.setId("myDefaultStyles"); document.getStyleSelector().add(style); final IconStyle iconstyle = new IconStyle(); iconstyle.setColor("a1ff00ff"); iconstyle.setScale(1.399999976158142); final Icon icon = new Icon(); icon.setHref("http://myserver.com/icon.jpg"); iconstyle.setIcon(icon); style.setIconStyle(iconstyle); final LabelStyle labelstyle = new LabelStyle(); labelstyle.setColor("7fffaaff"); labelstyle.setScale(1.5); style.setLabelStyle(labelstyle); final LineStyle linestyle = new LineStyle(); linestyle.setColor("ff0000ff"); linestyle.setWidth(15.0); style.setLineStyle(linestyle); final PolyStyle polystyle = new PolyStyle(); polystyle.setColor("7f7faaaa"); polystyle.setColorMode(ColorMode.RANDOM); style.setPolyStyle(polystyle); // <!-- Placemark #1 --> final Placemark p1 = new Placemark(); document.getFeature().add(p1); p1.setName("Google Earth - New Polygon"); p1.setDescription("Here is some descriptive text"); p1.setStyleUrl("#myDefaultStyles"); // <!-- Placemark #2 --> final Placemark p2 = new Placemark(); document.getFeature().add(p2); p2.setName("Google Earth - New Path"); p2.setStyleUrl("#myDefaultStyles"); {code} {card} {card:label=KML output} {code:xml|title=Listing Style.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Document> <Style id="myDefaultStyles"> <IconStyle> <color>a1ff00ff</color> <scale>1.399999976158142</scale> <heading>0.0</heading> <Icon> <href>http://myserver.com/icon.jpg</href> <refreshInterval>0.0</refreshInterval> <viewRefreshTime>0.0</viewRefreshTime> <viewBoundScale>0.0</viewBoundScale> </Icon> </IconStyle> <LabelStyle> <color>7fffaaff</color> <scale>1.5</scale> </LabelStyle> <LineStyle> <color>ff0000ff</color> <width>15.0</width> </LineStyle> <PolyStyle> <color>7f7faaaa</color> <colorMode>random</colorMode> </PolyStyle> </Style> <Placemark> <name>Google Earth - New Polygon</name> <description>Here is some descriptive text</description> <styleUrl>#myDefaultStyles</styleUrl> </Placemark> <Placemark> <name>Google Earth - New Path</name> <styleUrl>#myDefaultStyles</styleUrl> </Placemark> </Document> </kml> {code} {card} {deck} h3. {{<StyleMap>}} Original example can be found here:[{{<StyleMap>}}|http://code.google.com/intl/en/apis/kml/documentation/kmlreference.html#stylemap] {deck:id=StyleMap} {card:label=Fluent example} {code:title=Listing StyleMap (as fluent). } final Kml kml = KmlFactory.createKml(); final Document document = kml.createAndSetDocument().withName("StyleMap.kml").withOpen(true); // <!-- Begin Style Definitions --> final Style style1 = document.createAndAddStyle().withId("normalState"); style1.createAndSetIconStyle().withScale(1.0).withIcon(new Icon().withHref("http://maps.google.com/mapfiles/kml/pal3/icon55.png")); style1.createAndSetLabelStyle().withScale(1.0); final Style style2 = document.createAndAddStyle().withId("highlightState"); style2.createAndSetIconStyle().withScale(1.1).withIcon(new Icon().withHref("http://maps.google.com/mapfiles/kml/pal3/icon60.png")); style2.createAndSetLabelStyle().withColor("ff0000c0").withScale(1.1); final StyleMap stylemap = document.createAndAddStyleMap().withId("styleMapExample"); stylemap.createAndAddPair().withKey(StyleState.NORMAL).withStyleUrl("#normalState"); stylemap.createAndAddPair().withKey(StyleState.HIGHLIGHT).withStyleUrl("#highlightState"); document.createAndAddPlacemark().withName("StyleMap example").withStyleUrl("#styleMapExample") .createAndSetPoint().addToCoordinates("-122.368987,37.817634,0"); {code} {card} {card:label=POJO example} {code:title=Listing StyleMap (as POJOs). } final Kml kml = new Kml(); final Document document = new Document(); document.setName("StyleMap.kml"); document.setOpen(true); kml.setFeature(document); // <!-- Begin Style Definitions --> final Style style1 = new Style(); style1.setId("normalState"); document.getStyleSelector().add(style1); final IconStyle iconstyle1 = new IconStyle(); iconstyle1.setScale(1.0); final Icon icon1 = new Icon(); icon1.setHref("http://maps.google.com/mapfiles/kml/pal3/icon55.png"); iconstyle1.setIcon(icon1); style1.setIconStyle(iconstyle1); final LabelStyle labelstyle1 = new LabelStyle(); labelstyle1.setScale(1.0); style1.setLabelStyle(labelstyle1); final Style style2 = new Style(); style2.setId("highlightState"); document.getStyleSelector().add(style2); final IconStyle iconstyle2 = new IconStyle(); final Icon icon2 = new Icon(); icon2.setHref("http://maps.google.com/mapfiles/kml/pal3/icon60.png"); iconstyle2.setIcon(icon2); iconstyle2.setScale(1.1); style2.setIconStyle(iconstyle2); final LabelStyle labelstyle2 = new LabelStyle(); labelstyle2.setScale(1.1); labelstyle2.setColor("ff0000c0"); style2.setLabelStyle(labelstyle2); final StyleMap stylemap = new StyleMap(); document.getStyleSelector().add(stylemap); stylemap.setId("styleMapExample"); final Pair pair1 = new Pair(); stylemap.getPair().add(pair1); pair1.setKey(StyleState.NORMAL); pair1.setStyleUrl("#normalState"); final Pair pair2 = new Pair(); stylemap.getPair().add(pair2); pair2.setKey(StyleState.HIGHLIGHT); pair2.setStyleUrl("#highlightState"); final Placemark p1 = new Placemark(); document.getFeature().add(p1); p1.setName("StyleMap example"); p1.setStyleUrl("#styleMapExample"); final Point point = new Point(); p1.setGeometry(point); List<Coordinate> coord = new ArrayList<Coordinate>(); point.setCoordinates(coord); coord.add(new Coordinate(-122.368987,37.817634,0)); {code} {card} {card:label=KML output} {code:xml|title=Listing StyleMap.kml. The output of the POJO and the fluent example.} <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:ns2="http://www.w3.org/2005/Atom" xmlns:ns3="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0" xmlns:ns4="http://www.google.com/kml/ext/2.2"> <Document> <name>StyleMap.kml</name> <open>true</open> <Style id="normalState"> <IconStyle> <scale>1.0</scale> <heading>0.0</heading> <Icon> <href>http://maps.google.com/mapfiles/kml/pal3/icon55.png</href> <refreshInterval>0.0</refreshInterval> <viewRefreshTime>0.0</viewRefreshTime> <viewBoundScale>0.0</viewBoundScale> </Icon> </IconStyle> <LabelStyle> <scale>1.0</scale> </LabelStyle> </Style> <Style id="highlightState"> <IconStyle> <scale>1.1</scale> <heading>0.0</heading> <Icon> <href>http://maps.google.com/mapfiles/kml/pal3/icon60.png</href> <refreshInterval>0.0</refreshInterval> <viewRefreshTime>0.0</viewRefreshTime> <viewBoundScale>0.0</viewBoundScale> </Icon> </IconStyle> <LabelStyle> <color>ff0000c0</color> <scale>1.1</scale> </LabelStyle> </Style> <StyleMap id="styleMapExample"> <Pair> <key>normal</key> <styleUrl>#normalState</styleUrl> </Pair> <Pair> <key>highlight</key> <styleUrl>#highlightState</styleUrl> </Pair> </StyleMap> <Placemark> <name>StyleMap example</name> <styleUrl>#styleMapExample</styleUrl> <Point> <altitudeMode>clampToGround</altitudeMode> <coordinates>-122.368987,37.817634</coordinates> </Point> </Placemark> </Document> </kml> {code} {card} {deck} {column} {column:width=1%} {column} {column:width=29%} {livesearch:id=1|spaceKey=jak} [Java API for KML|Home] | [@Google|http://code.google.com/p/javaapiforkml/] {pagetree} {column} {section} |






is the OpenSource platform of 