How to copy and paste between Google's "My map" mashups
I've recently been having a lot of fun with Google's My Map DIY mashups. They really have made it dead simple to create your very own mashup, and even easier to embed them into your website. Honestly they are lot of fun and never fail to impress your average web user, I've lost track of the number of times people asked me how I did it. Compared to the old "edit in Google Earth", export, save to your website and hack up your own Javascript its a doddle!
However a couple of esential features are still missing from "My Maps" - the ability to copy a map, and the ability to import one map into another - essentially a "copy and paste" of information. This was bugging me because I have a bunch of maps of the district where I live and I was getting tired of trying to reproduce the non-trivial boundary of that district. Plus within it there are a couple of designated historic districts that I would also like to show in several places, again they have non-trivial boundaries.
Fortunately today I figured out how to do this and although not completely straight forward it is relatively easy. So here goes:
To copy a map go to your My Maps tab, select the map and locate the "View in GoogleEarth" link at the top right of the map, this is visible in both viewing and edit mode - and is available to anyone who has access to the map, not just collaborators. When you click on the link you should get the option to open it in GoogleEarth or save it (unless you don't have GE installed, in which case you'll probably be asked to save it or locate an app to open it with). Save it to a file - the extension should be ".kml"
Congratulations you have just exported your map to an XML format that can be re-imported to both Google Maps and Google Earth. And if you want you can open it with a text editor and modify the text, placemark names etc. manually.
To complete the copying of the map simply create a new map in Google Maps and then select the "Import" link. You will then get a popup asking you to either find the file on your hard-drive or to enter a URL to read a kml file from. It turns out that the hard-drive option doesn't work at the moment, or at least works only intermittently. I wasn't able to make it work at all. The workaround is to copy the kml file to a webserver somewhere that you have access to and then enter that URL when you attempt the import. If you still get an error then your webserver is probably not sending the correct MIMETYPE information for the file - this identifies its data type to the Google import code. Fortunately my hosting company already has the correct mimetype information on their servers, but you may not be so lucky. In which case visit this Google page for information on how to fix that. You may also have to consult your hosting company (if you are not self-hosted) to ask them how to add the mimetypes specified by Google.
So, once you have imported your content you should have a clone of the original map - which unfortunately exposes another bug which is when you import .kml file it also imports the map name from the .kml file and removes any map description you have already entered. So now click "Save" to save the map and you will see you have two maps with identical names. You will have to go and re-edit one of them to set the new name and decription.
To paste content from map to another e.g. Map A to Map B it is basically the same process except you copy the first map A to "Copy of Map A", then edit the copy to remove any unwanted content, then export "Copy of Map A", select "Map B", edit it and then select the import link. Enter the URL you saved "Copy of Map A" as and make sure you do not to click the "overwrite" option or you will erase all your "Map B" contents! Once again you will hit the bug that Map B will change its name and lose its description - even though it looks like it is okay before you hit "Save". So if you have any non-trivial description text first copy that text to somewhere (via Ctrl-C to the paste buffer, or to another file), then hit "Save". Google Maps will now list two maps called "Copy of Map A" - select the one that contains all the content you need, edit it and change the map name and insert the original description. Click "Save" and you are done!
While using the My Maps feature of Google Maps you will probably spot that you can display several maps overlaid on top of each other - just check the left hand box beside each one. But when you select view in Google Earth or "Link to this page" you will only get data or a view of a single map - the one that is currently highlighted in the map list on the left side. This is a shame but you can instead use the copy-paste method I described to merge several maps into one uber-map and link to that or export all the data for users to see in Google Earth. Hopefully Google will eventually update their mashups to include these features.
There may be a way to get around the overwriting of the map name and description by editing the .kml file before importing. Another solution may be to import the kml file into Google Earth and export it as a kmz file - I haven't tried this yet but will post update if I do. However the workaround for this bug isn't that hard just so long as you remember to make a copy of the map description that you are importing into. If in doubt use the "Copy map" procedure to make a backup copy first before you start importing stuff!


5 Comments:
That was really helpful. Thanks so much for posting.
As from today - the ""View in GoogleEarth" is GONE. very sad as I have lot of applications that used it...
Any idea how can I create the same saved files as "View in GoogleEarth" did ?????
thanks
gonen.s@sapiens.com
That was extremely helpful, thank you! I was able to save to local disk and then upload again without going the web server route.
THanks!Comforting to know that I wasnt the only one with problems with kmz upload.
Thanks for that, really useful. I was beginning to pull my hair out!
Post a Comment
<< Home