I'm running into a weird error with google earth KML tours. I have four different points i'm viewing with the camera look at feature. It works great moving from point to point up until the last point, then it "slingshots" backwards and flys to the final point. Any idea what is causing this or how to fix? In the google earth documentation they list a known issue as " and elements will break the curve created by a series of smooth FlyTos. FlyTo points on either side of these elements will be joined with a linear path.", but there is nothing linear about the slingshot error. Code is below, thank you.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<open>1</open>
<name>NewJersey to Chicago</name>
<gx:Tour>
<gx:Playlist>
<gx:FlyTo>
<gx:duration>5</gx:duration>
<gx:flyToMode>smooth</gx:flyToMode>
<Camera>
<longitude>-74.2340316009802</longitude>
<latitude>40.7126781884856</latitude>
<altitude>2490</altitude>
<heading>281.359605343224</heading>
<tilt>100</tilt>
<roll>0</roll>
<altitudeMode>absolute</altitudeMode>
</Camera>
</gx:FlyTo>
<gx:FlyTo>
<gx:duration>5</gx:duration>
<gx:flyToMode>smooth</gx:flyToMode>
<Camera>
<longitude>-74.314056000094</longitude>
<latitude>40.7243870914955</latitude>
<altitude>5150</altitude>
<heading>281.175459406497</heading>
<tilt>85</tilt>
<roll>0</roll>
<altitudeMode>absolute</altitudeMode>
</Camera>
</gx:FlyTo>
<gx:FlyTo>
<gx:duration>10</gx:duration>
<gx:flyToMode>smooth</gx:flyToMode>
<Camera>
<longitude>-74.6341362250194</longitude>
<latitude>40.771834073193</latitude>
<altitude>10150</altitude>
<heading>281.175459406497</heading>
<tilt>85</tilt>
<roll>0</roll>
<altitudeMode>absolute</altitudeMode>
</Camera>
</gx:FlyTo>
<gx:FlyTo>
<gx:duration>4</gx:duration>
<gx:flyToMode>smooth</gx:flyToMode>
<Camera>
<longitude>-79.1438605513884</longitude>
<latitude>41.3601193917472</latitude>
<altitude>10150</altitude>
<heading>281.175459406497</heading>
<tilt>85</tilt>
<roll>0</roll>
<altitudeMode>absolute</altitudeMode>
</Camera>
</gx:FlyTo>
</gx:Playlist>
</gx:Tour>
</Document>
</kml>
KML tours and the way Google Earth implements them are weird and mysterious indeed.
If you have a really fast segment (long distance in a short duration) that follows a slow segment in your KML tour, Google Earth implements the transition as if you're running backwards to get a running start for the faster segment (to build up momentum for the "jump", if you will).
This doesn't happen if your tour is roughly a constant speed. In your example, if you change your durations from <5,5,10,4> to <5,10,10,300> you will not get the running start effect.
Related
I have seen examples where it is possible to display a bitmap as a vertical profile in Google Earth. Like this:
However, I have not been able to find any kml/kmz examples of this. Does anyone have a simple example of how to do this?
Does it include using the dae (collada) file format too?
One method to do this would be to use a KML "Photo Overlay". They are designed to place landscape photographs vertically in the world, so that they can be viewed with the Earth terrain & imagery as matching background. You could use that technique to place images like these on vertical planes. There is a basic tool in Earth Pro to create Photo Overlays (Add menu >> Photo). Or you can create them manually or programmatically by writing the appropriate KML (reference links below), though it can get pretty complex with all the placement and field of view parameters. Also note that Photo Overlays work in Earth Pro (Earth v7.x), but do not currently work in Earth for web & mobile (Earth v9.x).
You could also do this using 3D models (yes, collada based) where you have a model representing your vertical plane(s), and the images as textures on the models. 3D models also only work in Earth Pro at this time. Which technique is easier will depend on the tools and skills you have available.
https://developers.google.com/kml/documentation/photos
https://developers.google.com/kml/documentation/kmlreference#photooverlay
My PhotoOverlay example is just here.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document id="7">
<visibility>0</visibility>
<PhotoOverlay id="8">
<name>PhotoOverlay Test</name>
<visibility>0</visibility>
<Camera>
<longitude>-122.3599987260313</longitude>
<latitude>47.62949781133496</latitude>
<altitude>100</altitude>
<heading>-90</heading>
<tilt>90</tilt>
<roll>0</roll>
</Camera>
<Icon id="10">
<href>foo.png</href>
</Icon>
<ViewVolume>
<leftFov>-45</leftFov>
<rightFov>45</rightFov>
<bottomFov>-45</bottomFov>
<topFov>45</topFov>
<near>20000</near>
</ViewVolume>
</PhotoOverlay>
</Document>
</kml>
My kml example using collada is here.
You have to prepare your_prepared_square.dae and your_prepared.png in same folder. The square size is 1m x 1m. This model is scaling base.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document id="1">
<Placemark id="2">
<name>My billboard</name>
<Model id="3">
<altitudeMode>absolute</altitudeMode>
<Location>
<longitude>140.037</longitude>
<latitude>36.84895</latitude>
<altitude>500</altitude>
</Location>
<Orientation>
<heading>90</heading>
<tilt>0</tilt>
<roll>0</roll>
</Orientation>
<Scale>
<x>1</x>
<y>10000</y>
<z>3500</z>
</Scale>
<Link id="4">
<href>your_prepared_square.dae</href>
</Link>
<ResourceMap>
<Alias>
<targetHref>your_prepared.png</targetHref>
<sourceHref>mapping.png</sourceHref>
</Alias>
</ResourceMap>
</Model>
</Placemark>
</Document>
</kml>
And mapping.png is texture filename in the collada model. This has
to be defined in the model. following fragment is a part of your_prepared_square.dae. But you don't need to prepare mapping.png. KML replaces it to your_prepared.png.
:
:
<library_images>
<image id="texture" name="texture">
<init_from>mapping.png</init_from>
</image>
</library_images>
:
:
folllowing image is applied this method.
I am attempting to generate a KML overlay. I have a grid I am mapping over an area, with colored squares. When I have the altitude mode as 'clampToGround' everything about the polygons I am generating, including their color, works as expected. However, it's not desirable to have the grid deform to map to the ground. When I change the altitude mode such that the overlay hovers a few meters off the ground, the shape of the grid sections is correct, but the color information is discarded and the grid sections are colored black.
Here is a testable excerpt of my KML code. Here is shows the colors correct but the grid deformed to the ground. Changing the value of altitudeMode to:
absolute produces the other behavior.
Is there a way to have this at the correct altitude AND with the correct color at the same time?
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document id="1">
<Document id="2">
<Style id="10">
<PolyStyle id="10">
<color>0xFF0000FF</color>
<colorMode>normal</colorMode>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>
<name>Antenna Data</name>
<Camera>
<longitude>-122.30201334502573</longitude>
<latitude>37.87244901754293</latitude>
<altitude>200</altitude>
</Camera>
<Placemark id="5">
<name>region</name>
<styleUrl>#10</styleUrl>
<Polygon id="4">
<altitudeMode>clampToGround</altitudeMode>
<outerBoundaryIs>
<LinearRing id="8">
<coordinates>-122.30243999999999,37.871973499999996,10 -122.30243999999999,37.8719265,10 -122.30238,37.8719265,10 -122.30238,37.871973499999996,10</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</Document>
</kml>
Your KML has several issues.
The polygon is missing the closing vertex. In order to be a valid KML polygon, the first coordinate set (lon,lat,alt) must be repeated as the last coordinate set, so that the polygon closes itself. For your example of a square, you would need 5 coordinate sets, with the first and the last being the same.
Try fixing that first, and if you still see coloring issues, try making sure that the vertex winding direction is correct (anti-clockwise). If it's backwards, then the darker "bottom" of the polygon will be facing upwards, and might appear dark/black. Yours appears correct from looking at the coordinates, but I could be mistaken.
Also, your color is not a valid KML color, as it appears to have an extra "0x" in front. A valid KML color needs four two-character values (each between 00 and ff), representing Alpha, Blue, Green, Red (AABBGGRR, and yes, it's backwards from HTML colors). A solid red would be: FF0000FF.
Below is an updated copy of your KML sample with altitudeMode = absolute, the closing vertex added, and the color corrected... this works for me in Earth Pro.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document id="1">
<Document id="2">
<Style id="10">
<PolyStyle id="10">
<color>FF0000FF</color>
<colorMode>normal</colorMode>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>
<name>Antenna Data</name>
<Camera>
<longitude>-122.30201334502573</longitude>
<latitude>37.87244901754293</latitude>
<altitude>200</altitude>
</Camera>
<Placemark id="5">
<name>region</name>
<styleUrl>#10</styleUrl>
<Polygon id="4">
<altitudeMode>absolute</altitudeMode>
<outerBoundaryIs>
<LinearRing id="8">
<coordinates>-122.30243999999999,37.871973499999996,10 -122.30243999999999,37.8719265,10 -122.30238,37.8719265,10 -122.30238,37.871973499999996,10 -122.30243999999999,37.871973499999996,10</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</Document>
</kml>
The solution I came across was that I could simple de-activate terrain in Google Earth. This seems to work now.
I have just started to learn how to manipulate the KML files. here is a problem that I do not know how to overcome.... I created a polygon and added a description to be shown as a balloon, but it appears as soon as Google Earth starts working before the polygon can be seen. what I want is to show the balloon from a specific distance where the polygon appears(for example in the range distance of LookAt element).
anybody knows how to manage that?
my code follows:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" mlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<LookAt>
<longitude>17.99514610290434</longitude>
<latitude>59.36293893395309</latitude>
<altitude>0</altitude>
<range>597.51212259908</range>
<tilt>52.34415598649959</tilt>
<heading>105.3974737169693</heading>
</LookAt>
<Placemark>
<name>Stadium</name>
<description>
<![CDATA[
this is <b><i>RĂ¥sunda soccer stadium</i></b>
]]>
</description>
<gx:balloonVisibility>1</gx:balloonVisibility>
<styleUrl>#msn_ylw-pushpin</styleUrl>
<Polygon>
<extrude>1</extrude>
<tessellate>1</tessellate>
<altitudeMode>absolute</altitudeMode>
<outerBoundaryIs>
<LinearRing>
<coordinates>
17.99514610290434,59.36293893395309,100 17.99651951950199,59.36209399425741,100 17.99752330705672,59.36252751885282,100 17.99613146514916,59.36335387902954,100 17.99514610290434,59.36293893395309,100
</coordinates>
</LinearRing>
</outerBoundaryIs>
</Polygon>
</Placemark>
</Document>
</kml>
Normally you can skip rendering the polygon until you get "close" enough to it as defined by a Region element which is determined by calculating when a given area maps to a min or max # of pixels.
Also, the <gx:balloonVisibility> tag forces the description balloon to appear when the KML is loaded regardless of whether Region is active. Adding a Region direct in the KML still shows the popup balloon.
To do what you want to do, you must wrap the KML file with a second KML file with a NetworkLink with a Region that loads the seconds KML only when the region is active (aka close enough) at which time the description is displayed along with the polygon.
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<LookAt>
<longitude>17.99514610290434</longitude>
<latitude>59.36293893395309</latitude>
<altitude>0</altitude>
<heading>105.3974737169693</heading>
<tilt>52.34415598649959</tilt>
<range>597.51212259908</range>
</LookAt>
<NetworkLink>
<Region>
<LatLonAltBox>
<north>59.363792</north>
<south>59.361556</south>
<east>17.998029</east>
<west>17.994443</west>
</LatLonAltBox>
<Lod>
<minLodPixels>128</minLodPixels>
<maxLodPixels>-1</maxLodPixels>
</Lod>
</Region>
<Link>
<href>target.kml</href>
</Link>
</NetworkLink>
</Document>
</kml>
And target.kml file contains the original KML you gave:
<?xml version="1.0" encoding="ISO-8859-1"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>Stadium</name>
...
</Placemark>
</kml>
You can change the distance the feature + balloon appears by adjusting the minLodPixels value and/or the size of the region. At present the feature will display when the region defined by area surrounding the polygon is at least 128 pixels on the screen. Change to 32 or 64 and/or make the region area larger to make it appear quicker.
Note Google Earth client doesn't give you a tool to edit or even see the Region bounding boxes on the map so debugging this is tricky. You can paste your KML into this tool to generate KML making the Region bounding area visible. This helps to debug Regions more easily.
I am pretty accomplished at using the animated update function of google earth and am using it to move models around. What I would really like to do is to be able to animate a line (eg up and down) in Google Earth but am finding this tricky.
I have the longitude and latitude of the line at the start. For example line coordinates are:
-88,17,100 -88.20270841086835,17.21899813162266,100
I then want to raise one end of this line up to an altitude of 500 over a period of 5 seconds.
I've drawn the line using LineString:
<Placemark id="path1">
<name>Untitled Path man</name>
<LineString>
<tessellate>1</tessellate>
<coordinates>
-88.,17,100 -88.20270841086835,17.21899813162266,100
</coordinates>
</LineString>
</Placemark>
But Im now lost as to how to use <gx:AnimatedUpdate> to move one end up from 100 to 500.
Im sure its easy - can someone point me in the right direction??
The trick is to update the LineString element (with an id on that) rather than the Placemark.
Here's a working KML example tour that animates a line changing from a relative altitude of 100 to 500m.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document>
<name>gx:AnimatedUpdate example</name>
<open>1</open>
<LookAt>
<longitude>-88.1351880996469</longitude>
<latitude>17.09943637744042</latitude>
<altitude>0</altitude>
<heading>49.91874373078863</heading>
<tilt>84.43764019949967</tilt>
<range>1929.311316966288</range>
<gx:altitudeMode>relativeToSeaFloor</gx:altitudeMode>
</LookAt>
<Placemark>
<name>Untitled Path man</name>
<LineString id="path1">
<tessellate>1</tessellate>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>
-88,17,100 -88.20270841086835,17.21899813162266,100
</coordinates>
</LineString>
</Placemark>
<gx:Tour>
<name>Play me!</name>
<gx:Playlist>
<gx:AnimatedUpdate>
<gx:duration>5</gx:duration>
<Update>
<targetHref/> <!-- Left empty to refer to the current file -->
<Change>
<LineString targetId="path1">
<coordinates>
-88,17,100 -88.20270841086835,17.21899813162266,500
</coordinates>
</LineString>
</Change>
</Update>
</gx:AnimatedUpdate>
<!-- Wait for the animation to complete (see the touring
tutorial for an explanation of how AnimatedUpdate's
duration isn't enough to guarantee this). -->
<gx:Wait>
<gx:duration>5.0</gx:duration>
</gx:Wait>
</gx:Playlist>
</gx:Tour>
</Document>
</kml>
For details see https://developers.google.com/kml/documentation/touring#tourtimelines
Hi I wrote a Javascript to output a KML file based on a polygon area marked on google maps api v3. The file used to worked correctly, showed the right location and polygon shape on Google Earth Pro
Now suddenly instead of showing the London Eye area in London it shows an area in Congo and the polygon doesnt even appear correctly on google earth. I tried to debug it appears that the coordinate seems to be causing the problem. However, when i save it to MyPlaces on google maps online it parses the KML and shows the shape and location properly. Thanks for your help. KML Below
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<Document>
<name>test</name><description>test</description>
<Style id='style1'>
<LineStyle>
<width>5</width>
</LineStyle>
<PolyStyle>
<color>0FF00000</color>
<fill>1</fill>
<outline>1</outline>
</PolyStyle>
</Style>
<Placemark>
<name>?</name>
<styleUrl>#style1</styleUrl>
<Polygon>
<outerBoundaryIs>
<LinearRing>
<tessellate>1</tessellate>
<coordinates>
51.50519078602326, -0.12681582942195746,
51.50708732603467, -0.12381175532527777,
51.50553804573176, -0.1123104430694184,
51.50166461450478, -0.11462787165828558,
51.50519078602326, -0.12681582942195746,
</coordinates></LinearRing></outerBoundaryIs></Polygon></Placemark>
</Document>
</kml>
Your KML is invalid, and Google Earth is no longer as permissive as it was in accepting this type of invalid coordinates.
Specifically, you have an extra comma at end of each line in your KML -- so just remove them, or else add the optional altitude value after them.
Also remove the whitespace between the separate parts of the coordinate. Your coordinates will now be converted to three separate coordinates by Google Earth:
51.50519078602326,0,0 and -0.12681582942195746,0,0 and 0,0,0.
Change it to:
51.50519078602326,-0.12681582942195746,0
51.50708732603467,-0.12381175532527777,0
Or:
51.50519078602326,-0.12681582942195746
51.50708732603467,-0.12381175532527777
See https://developers.google.com/kml/documentation/kml_tut#polygons for a polygon example or the section and https://developers.google.com/kml/documentation/kmlreference#linearring for extra details.