A quick start to using the google maps api

 

I found this really useful site on the ArcGIS site

Here is a quick summary.

1 Get a Google Maps key, you will need a google account for this. Then Sign in here for the key.

You will need a site, I am using this privatewww site, which is http://privatewww.essex.ac.uk/~kwilding

I have now had a key generated, this will ONLY work for me:

ABQIAAAAv_8wbruG3ITBqZHSGpc8HhQkn1DgQC9HeTEb17tJeNGVDYkdoRSXN9PK_6FFdvLOB7XqNQopFALfEQ

which is for use at this site ONLY. You are also provided with a page of code, which I will call GIStest.html ; this was produced by copying the code provided into the source code of the page, overwriting anything that already existed in this code.

Incidentally, make sure you type the url completely as http://privatewww/~kwilding will fail !

OK, back to the GisARC instructions. Read the instructions, copy the code from step 6, and add your own key to this. I have saved this as GIStest2.html

Now, back to the recommended google api site; I copied the code from the map3 here ; pasted it into a new empty page as source code and overwrote the scrip src line (about line 4) with a similar line from one of the previous pages, this has the correct api key - try the page now, this is GISmap1 - actually, it is not fully operational yet. Get the xml data, and save this as example.xml in the same folder, and try again. Cool.

 

More to follow, but just a proof of concept for a course next year. Now for an example that uses a map closer to home, finding the co-ordinates that we need.

Try this site - this finds Colchester campus as Latitude, Longitude
51.876421,0.945028 - copied GISmap1 as ColchesterMap, edited the example.xml and changed the co-ordinates to get a feel, the third number is the zoom, and increased this to 18.

Also, I want a different maptype - a satellite map, just add a single line of code:

 map.setMapType(G_SATELLITE_MAP);

Here are the differing types:

GPS data tracking:

Using Colchester, and directions from the A12, you can try this excellent  online program to produce a gps file. (I might have to save this as text, you will need to rename it!)

Once you have this, save it on your local drive, and then run it from this online program to show the actual gs mapping.

If you are following along with the example, it is very rough, and is just a set of points and polylines. If you use too large a map, then these do not actually follow the line of the road! I think the trip also finishes in the middle of a field, but obviously, this can be repeated as many times as you like.

Next, how do we use this in a program on our own web pages? Well, it seems that polylines are actually created slightly differently. Visit this polyline encoder program . After running the program you should have something like this colchester-polyline

The string of characters does not make any sense, but can be decoded using this decoder page which outputs a set of lat / long points