How to Add shapefile/mapinfo polygon data into google maps (IE, Firefox, and Safari only so far)

Example of a polygon file of Ontario townships added to Google Maps Ontario Townships . This is a subset of an Ontatio Geospatial Data Exchange (OGDE) township layer file.

There exists plenty of documentation on the web on adding points and polylines to google maps, but very little on how to add polygons. I hope this documentation will be useful to others as it can take quite a while to figure all of this out (as I found out). This documentation is meant to be used in a windows environment running php on command line. If you know of any other methods to add polygons, please let me know, but so far this is all I've been able to find, other than the following site that lets you load a shapefile for a one time only map


1 - Here are the steps required to add shapefiles or mapinfo (*.mif) to your google maps. If you have google maps installed on your server already, skip to step 3.

2 - Set up your Google map service by first applying for a google maps api to allow you to use their map service in your web pages. See . This key is good for only one directory on your web server but can be used on as many maps as you want (see restrictions in the terms of use agreement). If you want to add other maps in other directories, there is nothing stopping you from requesting subsequent API keys.

3 - Ensure that php is running on your server or your desktop (in this case you only need php to run one processing script). If php is not installed, installs are available from (including command line for windows). Help with running a php script is also available on this page.

4 - Get mif2gmap.php script from and unzip the files in a directory (your choice).

5 - Edit the index.php script to suit needs (ie. change your google API key to the one for your site, set the center of the map to the coordinates you want to center your google map on, title of the web page you're creating, etc.)

6 - If using shapefiles, convert your polygon shapefile to mapinfo (mif) format using either FME or other GIS tools such as the free ones found at or

7 -Place *.mif files in the "MIFs" folder (without quotes) where you unzipped

8 - Run index.php script in the following manner

"index.php > nameoffile.html"

(without quotes) where "nameoffile.html" (no quotes) is the file you want to create with the polygons attached to your google map

9 - Place "nameoffile.html" (no quotes) in your web space

10 - Ensure that you have also placed the javascript file "xmaps.1.js" (no quotes) included in the file in the same folder as your newly created "nameoffile.html" file

11 - Edit and customize your new maps as you see fit. Note, the php script was written by Matt Farley. His web page can be found at

This page: