Main Content

Controlling and labelling Google maps via PHP

Archive - Originally posted on "The Horse's Mouth" - 2007-10-13 00:23:56 - Graham Ellis

"Can you use PHP to control what you show on a Google Map?" An innocent question that lead me off on an interesting exploration when I should (!) have been doing other things - but a very worthwhile couple of hours, and great fun!

How do you do it?

1. Apply for your Google Maps key (you'll need to set up a Google account first if you don't have one)

2. Load their sample Javascript into the head of your web page, and modify it to relect your scale and location.

3. Add in a <div id="map" ... element to your web page

Probably a good idea to test at this point!

4. Add in a form for the controls you want, a handler for form inputs, and modify the Javascript to drop in the contents of PHP variables where necessary.


And Bob's your uncle!

I have an example in use here.
And the source code is here.

Is there much else I could do? Absolutely! I've just pushed the door open a crack and I see a blinding light shining out.