Displaying local file in Google Maps?
How can I get a KML/KMZ file to display on Google Maps without a public facing web server?
The ironic thing about your question is that you are connected to the Internet. How do you get Google Maps?
by "without a public facing server" do you mean the kml *has* to be on the local machine, or that you don't want to have to bother with installing/configuring/buying a public website? And, does the custom map you want to make need to be seen by others or just you?
THe situation is "I can get to the internet, but the internet can't get to me." In that case, you can't use the KML-file support in the Google Maps API.
You can download KML / KMZ to Google Drive, it natively supports visualization https://docs.google.com/file/d/0B9sBXp66G86xWmlRbkZiYlRNdmc/edit
To open a KML or KMZ file in Google Maps, I append the following prefix to an online link of the KML file:
Typically, I put the KML or KMZ in my dropbox, and then copy/paste the public link to the end of the above snippet. Then I can email that link to whom ever wants it, or I post it online somewhere. I've also used Google Docs to store the KML's, and a Links page on my website to distribute the links.
Harvey Mountain Hike:
Technically, are you supposed to URL-encode the Dropbox URL when passing it as a parameter?
This approach doesn't appear to work any more. Upon clicking the above link, I just get google maps with your dropbox link in the search box.
Working with KML on http://maps.google.com will soon be deprecated though: https://support.google.com/maps/answer/41136?hl=en
I have found that you can simply click on the share link from Google Drive and the KMZ will automatically load in Google Maps without any other need for extension. Tested in Chrome and Explorer.
For what @EmilBrundage said to work, I needed to add a plug-in to Google Drive. But the exercise lead me to http://kmlviewer.nsspot.net/, where I could just type the URL for the KML I wanted to view, and it worked. It's a pity Google has made this hard.
Is this for something that you want to have permanently available to others, or just for temporary viewing?
One of the tricks that I use quite often is to place the KML file in my public DropBox folder (find someone with an account to refer you; it will get both you and them an extra 250Mb) and then paste that url into Google Maps to visualize and share with others short-term.
In the longer term, you do have the option of creating a new Google "My Maps" map, and importing KML, KMZ or GeoRSS into that. Once done, you can share the resultant map using the standard My Maps tools.
You can also use Google Docs to store and share KML files with others. My recommended technique is to:
- Create a folder and mark it for public access.
- Use the Upload link to upload your KML files into this folder without conversion and shared with the world
- Go to the Download link, copy it, and paste it into the Google Maps search box
I wonder how long before Google allows interactive collaborative editing of KML documents via Google Docs? Now that would be cool...
You can upload a KML file to Google Maps:
- Log in to your Google Account, and go to http://maps.google.com
- Click on
Create a new map
- Add a title and description
Choose file, select the KML to upload, and then click
Upload from file
Now you're done :)
Interesting, this is the answer that most directly addresses the question.
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.
I used to display local .kml and .kmz files in google maps, but now i can't :(
The short answer is: you can't. Using a local file with the plain old Google Maps web application would violate the browser's sandboxing and same origin policy.
One option, however costly, is that you may be able to use Google Maps Premier to host the maps-x.js on your local filesystem along with the associated KML.
Another option is to use an existing public facing web server, like Google Sites.
Also, keep in mind that you may be able to use OpenLayers as an alternative to Google Maps Premier.
OpenLayers will be limited (in modern browsers) to non-file URLs, at least in Firefox, but you can set up a local/non-public webserver and use that. Note that the "Sandboxing" isn't really the reason that you can't do what you want with Google: If an HTML page is hosted on your local server, the JS should be able to read a file from the local server. You only can't because Google parses all files on the server side -- so their server needs to talk to your server, which it can't.
Click Import. You can import CSV, TSV, or XLSX files, My Maps, or spreadsheets from Google Drive. KML import is not currently supported.