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

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.

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.

Google Maps will not load KML layer from my site

I have a site that contains kml. The kml is shown as a layer in Google Maps. The maps are on the same site. Until recently (may 12th), this worked fine, but now it stopped working. The kml itself is OK, it can be used in Google Earth. When I copy the kml to another site I can load it in Google Maps without any problem.
Is it possible that my site is on a "blacklist" for some reason? Traffic is low. I did not use an API key. I do now but that did not solve the problem.
You can see the difference here:
1 - with kml from my site
2 - with kml placed elsewhere
The first one fails, the second one works. The kml placed elsewhere is an exact copy of the kml from my site. The kml from my site is served with media-type application/vnd.google-earth.kml+xml. It is dynamically generated.
In my case i got FETCH_ERROR on kml status-
Because my site allow only tls 1.2 secure connection.
When i put the files on another server- it's work.
Update 1-
It happend again after sometime, this time use the same domain helped.
from the Google Maps 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.
Both are valid, the one that doesn't works returns a KmlStatus of FETCH_ERROR. As a guess, I would say that the dynamic generation is taking too long. But there might be some security on your server that is preventing Google's server from fetching it.
from the documentation
FETCH_ERROR The document could not be fetched.
from your site
doesn't work with Google Map KmlLayer
Returns KmlStatus: FETCH_ERROR
Works through a proxy with the third party parser geoxml3
placed elsewhere
works with Google Maps KmlLayer
The problem automagically solved itself by waiting a few days. We can only guess what caused it, maybe a temporary glitch on our server which caused Google to stay away for a while and/or sploil it's cache. Anyhow, thanks for the reactions, at least I learned something about testing my kml.

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.

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.

KML overlay as string

Is there any way to create a KML overlay in Google Maps by passing the KML as a string rather than as a publicly accessible URL? AFAICT there is no such option in the Google Maps API v3. I am not asking about the API but about possible end runs around this limitation.
Personally I can think of only one: to parse the KML and generate equivalent JS. Does anyone have a better suggestion?
geoxml3 has a parseKmlString method, which will parse a string of kml and can create native google maps API v3 objects from it. I have used it to parse kml fragments out of FusionTables.
I've tried too but i haven't found a way to do this.
The reason is explained here: https://stackoverflow.com/a/6152916/2131283
For the tests my work around was sharing the kml file on my dropbox then give the direct access url with the token to the constructor
kmlLayer = new google.maps.KmlLayer
url: 'https://dl.dropboxusercontent.com/s/eg/gmaps.kmltoken_hash=HASH_CODE&dl=1'
Looking over the API it doesn't appear that this is possible.