links in kml balloons not working in GE 6 - kml

My KML placemarks have the description element populated as such
<description>
<![CDATA[
some text
someTag
]]>
</description>
With Google Earth 5, when you click on the link in the balloon, the kml is downloaded and displayed as expected.
With Google Earth pro 6, when you click on the link in the balloon, nothing happens. You have to right click on the link and then select "Open in New Window". Then the KML is downloaded and displayed in Google Earth.
Does anyone know why there is the behavoir difference between GE 5 and GE6? How do I get links in kml balloons to download in GE6 without requiring the right click workaround

There were some updates to handling URLs and hrefs between GE 5 and 6. GE 5 allowed some sloppy URLs and 6.0 became stricter in a few places to better conform to the specs. There weren't a lot of details on the specifics. Check the syntax of the URL and make sure it opens in your web browser.
Note if you want to fly-to a target Placemark in another KML file you specify the id of that Placemark as an anchor in the URL with a "#" followed by the id (see example below in second link).
Here's a KML example that works in GE 6.2.2:
<?xml version="1.0" encoding="utf-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>Test</name>
<description>
<![CDATA[
test URL#1
<P>
test URL#2 w/anchor
]]>
</description>
<Point>
<coordinates>-123.0821604290386,37.42041505714916</coordinates>
</Point>
</Placemark>
</kml>

Related

How can I upload a KML file to a website for an organization with multiple locations?

I am trying to update a KML file for a website that has a multiple locations and having some trouble. I want to use it accordance with schema.org to get rich snippets in Google search results. My problem is I can't find a solid answer on how to relate multiple listings to the proper pages.
I think I understand how to create the KML file from these resources.
https://developers.google.com/kml/documentation/kml_tut
http://sixrevisions.com/web-development/5-little-known-web-files-that-can-enhance-your-website/
Here is my example code:
<?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>
<name>Hospital 1</name>
<description>Our first hospital</description>
<Style id="pin"><IconStyle><Icon><href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href></Icon></IconStyle></Style>
<Placemark>
<LookAt>
<longitude>-0.13642</longitude>
<latitude>50.819522</latitude>
<altitude>0</altitude>
<tilt>0</tilt>
<range>5500</range>
</LookAt>
<styleUrl>#pin</styleUrl>
<Point><coordinates>-0.13642,50.819522,0</coordinates></Point>
</Placemark>
</Document>
</kml>
I know that it has to be in the root folder and named after the site. But how do I name different locations or associate them to a certain page? Can I put the kml file on the different location pages?
I might be thinking about this in the wrong way so any help would be greatly appreciated.Thank you.
From your sixrevisions.com link, the part you are missing is that you have to reference this KML file on your webpage with a LINK tag:
<link rel="alternate" type="application/vnd.google-earth.kml+xml" href="SixRevisions.kml" />
The location and name of the file aren't important (as long as you update the href attribute). You can put this tag on whatever page you want so you can point each page at a separate file.

How to create Google Earth KML network link that does not allow folder to be expanded

I have created a network link that references another KML file with actual data to be loaded into Google Earth. My issue is that the number of points in the referenced KML file is so large that it crashes Google Earth if the KML file folder underneath the Places tab in Google Earth is set to "Allow this folder to be expanded" (right-click KML, properties). By default, this checkbox is checked. I want to make it so that for every network link I create the folder by default will not be expandable.
I have looked up checkHideChildren in Google Earth KML tutorials, but that line provides no results, and I am not entirely sure where I am supposed to place the line in the Network Link KML.
Here is example code, if you could point me in the direction where to place this line of code, or an entirely different approach, it would be greatly appreciated!
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.1">
<NetworkLink>
<name>
CPU
</name>
<refreshVisibility>1</refreshVisibility>
<Link id="GPS_Plotter Updater">
<href>CPU.kml</href>
<Style id="style1"><ListStyle>
<listItemType>checkHideChildren</listItemType> <-- this is the line that should be hiding the children points of the KML!
</ListStyle>
</Style>
<styleUrl>#style1</styleUrl>
<refreshMode>onInterval</refreshMode>
<refreshInterval>1</refreshInterval>
<viewRefreshMode>onRegion</viewRefreshMode>
<viewRefreshTime>1</viewRefreshTime>
</Link>
</NetworkLink>
</kml>
Try putting the Style element in the NetworkLink, not the Link element. Link doesn't take a style selector, but NetworkLink does. If that doesn't work, try a listItemType of radioFolder instead.
In addition to Mano Marks' suggestions you also need to move the styleUrl element to the NetworkLink otherwise it won't apply. Note in your example you have viewRefreshMode=onRegion but don't have a region defined for it.
Here's the complete working example to suppress the NetworkLink contents.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<NetworkLink>
<name>CPU</name>
<styleUrl>#style1</styleUrl>
<Style id="style1">
<ListStyle>
<listItemType>checkHideChildren</listItemType>
</ListStyle>
</Style>
<Region>
<!-- define region here -->
</Region>
<refreshVisibility>1</refreshVisibility>
<Link id="GPS_Plotter_Updater">
<href>CPU.kml</href>
<refreshMode>onInterval</refreshMode>
<refreshInterval>1</refreshInterval>
<viewRefreshMode>onRegion</viewRefreshMode>
<viewRefreshTime>1</viewRefreshTime>
</Link>
</NetworkLink>
</kml>
You can catch errors like this by validating your KML. Try using the Galdos KML Validator.

Google Earth link PDF or image file on company server to placemark

I want to display multiple jpg(s) and/or pdf file(s) to a single placemark. The file path is in my company's directory and I would like anyone in the company that I send this google earth file to have the ability to view each placemark.
I have tried the command and neither seem to be working.
Both of these commands work with images at a "http:// address" but not with references to my hard drive nor server.
A KML Placemark can contain any number of images in its description. Most HTML will render inside the description of any given Placemark.
Option 1. Linking to a PDF or other media via URL within KML
Here's sample KML file to launch in Google Earth which will show an inline image in the popup balloon with a link to a PDF file:
<?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">
<Placemark>
<name>Test</name>
<snippet/>
<description>
<![CDATA[<a href="http://stlab.adobe.com/wiki/images/d/d3/Test.pdf"><img
src="http://stlab.adobe.com/wiki/skins/common/images/icons/fileicon-pdf.png"></a>
]]>
</description>
<gx:balloonVisibility>1</gx:balloonVisibility>
</Placemark>
</kml>
Note the gx:balloonVisibility tag which if set to "1" will auto-display the popup. That's a useful feature.
If images are within your hard-drive then you won't be able to share the KML with others unless you either bundle the images inside a KMZ file or publish the images to web site in your company so they are accessible via a URL.
Option 2. Embed the PDF within the Placemark description balloon
One trick to directly embed the PDF within the Placemark description balloon is using the Google PDF viewer in an iframe and substitute the test URL for actual URL in link below.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Placemark>
<name>Test</name>
<snippet/>
<description>
<![CDATA[
<iframe src="http://docs.google.com/gview?url=http://stlab.adobe.com/wiki/images/d/d3/Test.pdf&embedded=true"
style="width:718px; height:700px;" frameborder="0"></iframe>
]]>
</description>
</Placemark>
</kml>
This technique doesn't need a Flash player and works in Google Earth.
Note if you do this too many times and/or try for very large documents then the viewer will display the message:
You've reached the bandwidth limit for viewing or downloading files that aren't in Google Docs format. Please try again later.

Google Earth Plugin: Browsers other than FF show HTML markup when using .getBalloonHTML() to dump placemark contents into a DIV

I'm trying to dump Google Earth placemark content into a div outside the plugin, and it works as expected in FireFox, but not in Chrome, Safari, or IE. The later 3 display:
<!--Content-type: mhtml-die-die-die-->
at the beginning of the placemark contents and the HTML markup is shown with the other contents. FF parses the contents as actual HTML and so it displays correctly formatted as expected.
Would anybody know how to get the other browsers to parse the content as HTML as opposed to whatever they are doing right now?
The following is my GE plugin code:
currentKmlObject = kmlObject;
ge.getFeatures().appendChild(currentKmlObject);
google.earth.addEventListener(kmlObject, 'click', function(event) {
event.preventDefault();
var placemark = event.getTarget();
var content = placemark.getBalloonHtml();
document.getElementById('balloonContents').innerHTML = content;
document.getElementById('balloonContents').innerText = content;
I am using fetchKml to load the KML data from another URL which is setup as follows:
<?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>
<Placemark>
<name></name>
<description>
<![CDATA[ HTML CONTENTS ]]>
</description>
<Point>
<coordinates></coordinates>
</Point>
</Placemark>
</Document></kml>
Many thanks in advance.
I figured it out. It has nothing to do with Google Earth or KML. For some reason I accidently assigned the placemark conntent to innerText. I only needed to assign it to innerHTML.

KML file not showing correct location and polygon orientation. Syntax issue?

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.

Resources