PB, I have been curious for a long time about the Google Maps API.
I am not a programmer, but years ago (20+
) I wrote a lot of C code, and can muddle my way with perl. With help from templates I even wrote a Javascript
book time calculator.
Currently I embed Google Maps in my text by saving them on the Google site and using their tools to produce an ambedded map, see for example
From Zinal to Hotel Schwarzhorn in Gruben.
How difficult would it be to do the same with the .kml file on my computer, and would I have additional customization options?
Thanks!!!
The difficulty would be getting up to speed, not laying the data onto the map. There are many tools in the API to take data from KML, XML and other structured data files and put the data on the map. But --- Google Earth does that too and some times by just dragging and dropping. The problem with that however is that YOU can see the maps but your friends can't. So I choose the API route so it could go on my web site (just a freeby site provided by Verizon, my service provider).
The language of the API is javascript - a very flexible OO language. If you're an old C programmer, you'll soon get to the point of saying "Wow, you mean they let you do THAT!". Unfortunately, greater flexibility in a programming language allows you many more ways to make mistakes.
I signed on to the Google API developer group (
http://groups.google.com/group/Google-Maps-API?pli=1) and signed up for a map key (a character string that lets you serve maps from your web site - yes free, and no ads). Pretty soon I managed to get the "Hello World" sample map working, and the rest, as they say, is history.
I suggest you look at the source for my map linked above. If it's total gibberrish, then let it go. But if it looks like it makes sense and you have some time to put into it, follow through. Warning: that particular map routine has tons of special features that have accumulated over the last year or two, so what started out simple, is now getting a bit complex.
The best thing I did, was to change from a one-off map approach, to a general purpose routine driven by a data file. This increased the complexity and took a while to implement, but means that now I just need to add the data for a particular trip (somewhat equivalent to your KML files) and it's up and running.
So for example, when I decided that track logs would be nice to have, I used an pre-existing format for the set of latitudes and longitudes, and then wrote a function to put them on the map. Not as simple as Google Earth, but not too bad. Then subsequent track logs were just a matter of sticking the data into the map file, give it a name (like "Peaked Mtn track Log") and it's done.
As for embedding, I just stick them in an IFRAME (an HTML element) which is just what Google uses. So for example, if you move to the next section of my trip report and look at the first set of photos, (
click here) you will see a link for "Driving Directions Google Map" at the bottom of the list of photos. Click on that - it's a real life embedded map which I got on-line and then clicked where it says "Link" at the top right of their map and used their code. In fact if you click on the Google Logo at the bottom left of that embedded map in my report, you'll get the original (UNembedded) Google Driving Directions. I believe that's exactly like what your sample does (where is that? Alps?).
But let's face it - part of the reason I like this approach is that I can spend my time creating my own thing (much like the 1000s of others out there doing their own thing). Google is smart - they have a product that is just right for each segment of the internet community. This API is for two niche groups of people: 1) geeks like me and 2) those who hope to make money by producing custom maps for customers (certainly not me, although I've been approached).