Can I display some KML on a Google Map? - google-maps

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).

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.

Getting pins from a saved Google Map into v3 API

I have a saved google map in 'My Places', with over 100+ pins added for locations around the UK. Is there any way I can avoid having to use the embed feature to display this map on a webpage, sort of calling the saved map by ID via the google API?
Essentially what I want to do is get access to google's new visual refresh and be able to control the settings of the map more with API.
The map link is this: https://maps.google.co.uk/maps/ms?msid=207590858966548688521.0004aa52150024d3431b2&msa=0
Can we parse anything here...?
You can overlay the KML output by MyMaps using a KmlLayer in the Google Maps API also:
your MyMaps data displayed on an API based map
Updates in MyMaps will (eventually) be reflected on the map.
Using https://mapsengine.google.com I was able to import the maps data and utilise the pins that way. Not ideal, but still some better functionality.

Google Earth loads KML 2.2 but not 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.

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 with custom GEORss file

Where would I need to host an xml file in order to use it in Google maps for GEORss ??
From google api docs...
var georssLayer = new google.maps.KmlLayer('http://api.flickr.com/services/feeds/geo/?g=322338#N20&lang=en-us&format=feed-georss');
georssLayer.setMap(map);
this seems to do a great job of creating the info popouts and everything...
It would seem i cannot have one locally...
So i guess i need an aspx or ashx to push the xml...but does it have to be web accessible?
Thx
Yes, it needs to be web accessible because Google converts the GeoRSS to KML on the server side:
"The Google Maps API supports the KML and GeoRSS data formats for displaying geographic information. These data formats are displayed on a map using a KmlLayer object, whose constructor takes the URL of a publicly accessible KML or GeoRSS file.
The Maps API converts the provided geographic XML data into a KML representation which is displayed on the map using a V3 tile overlay."
http://code.google.com/apis/maps/documentation/javascript/overlays.html#KMLLayers
If you are hosting a static XML file, you might use Amazon Web Service's Simple Storage Service: http://aws.amazon.com/s3/