Google Earth loads KML 2.2 but not Google Maps - google-maps

The Google maps script I have seems to load the example KML from Chicago files fine, but when I add my own, it fails. The KML standard is 2.2 - why doesn't Google Maps manage to read it (Google Earth seems to work fine)? When I tried to validate the file it said there were some errors - is there any way around it given that this is an output I get from an application?

geoxml3, KmlLayer and Google Maps load your kml for me. My server doesn't support KML with the .kml extension, just as XML with the .xml extension because it isn't configured for the KML/KMZ MIME types, you might have the same problem on your server.
See this issue on the Google Maps API v3 issue tracker regarding the "spikes" on the line.
Another option would be to to see what KmlLayer.getStatus() returns (Kml Status:DOCUMENT_NOT_FOUND). The cta.kml example returns Kml Status:OK.

Related

Google Maps q parameter for adding a KML with URL stopped working

On our website we have several map previews for various KML datasets. When clicking the preview button the link would go to:
http://maps.google.com/maps?q=http://magic.lib.uconn.edu/magic_2/vector/37800/statect_37800_0000_2010_s100_census_1_kml.kmz
which would show a map with the overlaid KML file.
Support for this syntax from Google Maps apparently has stopped working recently, and I cannot find any new information about adding KML layers to a Google Map using the q parameter in a URL. Most of the resources I have found are for JavaScript or embedding maps, which hasn't been helpful. I have also found this thread from StackOverflow (Why has google maps "q" parameter stopped working?) but this is related to a specific location rather than adding a KML file. If anyone has new information or can help, that would be greatly appreciated.
See KML files on Google Maps in the documentation.
From February 2015, maps created in the classic Google Maps — https://maps.google.com/ — will no longer load KML/KMZ files from external websites. However, we know that KML files are a really useful way to work with geographic data, so we’ve added KML to Google My Maps, and continue to support this format with other Google Maps APIs. We hope that one of these options will meet your needs.
There they only list:
Google My Maps
Google Maps JavaScript API
So if you can't use Google My Maps or the Google Maps Javascript API v3, you may be out of luck.
Another reference from "support" is:
KML content isn't available in Google Maps
While using Google Maps, you might have received a notification saying "Some custom on-map content could not be displayed."
That’s because a certain type of content isn’t available anymore in the classic version of Google Maps or in maps embedded on other websites from the classic version of Maps. The content type that’s no longer available is KML, the file format Google Earth uses for the exchange of geographic information.
If you're the owner of a custom map with KML content, you need to update your content. Or, you can import your KML content into My Maps.

KML file from Massachusetts GIS - display in Google Maps API

I've been pulling KML files from the Mass GIS service via their export feature:
http://maps.massgis.state.ma.us/map_ol/oliver.php
For example, a KML output of Population Density per Square Mile looks like this when exported:
http://evrkusd.fatcow.com/populationpersquaremile.kml
I try to add it to my Google Map and nothing shows up, although this code works fine with other kml files from other sources.
var NewLayer = new google.maps.KmlLayer('http://evrkusd.fatcow.com/populationpersquaremile.kml');
NewLayer.setMap(map);
I'm getting the idea that some of the kml tags are outdated or are not accepted by Google Maps API.
Is anyone able to get this file to work for them? Any ideas how I can (preferably easily) update this file to work with Google Maps? I'm going to be using multiple KML files like this, so I'm hoping I can do a fairly quick fix.
Your KML file is still too big:
http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/populationpersquaremile.kml
If you click on the "load KmlLayer" button, it will show you the status return by attempting to load that file in KmlLayer:
Kml Status:DOCUMENT_TOO_LARGE
Your "partial" KML files are not valid xml, if I make the one you posted valid, it works with geoxml3, but the Google Maps API v3 KmlLayer still says it is too big.
See the documentation, the maximum fetched size of a raw KML file is 3M, your file is 7M+.
Fusion Tables can handle much larger KML than client-side maps, up 100MB total (though some limits apply to features). So that might be a solution.

Can I display some KML on a Google Map?

Is it possible to have some KML hardcoded into some Html page and have google maps display that hardcoded KML to a google map?
Right now, I keep seeing documentation that requires the KML to be located somewhere else -> an HTTP endpoint on some webserver (which is not what I want).
Any ideas?
The geoxml3 KML parser will parse a KML string embedded in your page and display it on the map (as native Google Maps API v3 objects, not a KmlLayer, that does require a publicly available KML file).

Google maps (API v3) with kml layer. how to hide kml URL?

I would like to di splay a Google Map with a kml inside through API v3. the proble is that every one can see the url of the kml and easily download it. Is there a trick to 'hide' the .KML URL?
wikimapia.org seems to do something similar displaing kml polygons but if you check with Firebug through the script tag you won't see the kml URL.
thanks everyone for help.
A. from Italy.
You could generate it at run time, so that the server sends the page the URL. However, it is still discoverable at some point. Security through obscurity just doesn't really work. The KMLLayer Layer requires your KML to be on a public server. You could instead parse the KML and render it that way, say using egeoxml. However that delivers much less performance.

Google Maps kml files

If I use an embeded google map in my website, will the data contained in an kml displayed be publicly viewable?
Will it be possible for the user to access just the data displayed (i.e., not the user interface) or would I have to provide that separately?
If you load your KML through the API, with GGeoXml(), (V2), or KmlLayer(), (V3), then your data needs to be in a public server because it is parsed by Google's servers and they need to be able to get to it. If you load it with a third party extension then you can keep it private.
Third party extensions that can load and parse KML data are EGeoXml() by Mike Williams
http://econym.org.uk/gmap/extensions.htm#EGeoXml
and GeoXml() by Lance Dyas
http://www.dyasdesigns.com/geoxml/
but I believe that both of those are only available for the API V2 for now.
I just upgraded my Google Maps JavaScript API Application from v2 to v3, following these instructions.
My v2 application was using the EGeoXml extension referred to by #Marcelo in the accepted answer to locally parse KML data.
A substitution of geoxml3 in its place, as suggested by #geocodezip (a contributor to the project) in a comment, functioned immediately in my v3 application.
No, the data will not be public. I'm not sure about your other question though.