Monthly Archives: October 2010

GeoJSON to Google Maps Utility

A few months back I posted code on my demo page for converting GeoJSON polygons to Google Maps polygons. Since then I’ve needed to create similar code for points and lines as well. I’ve pulled all of them together and pushed them to GitHub. This should work for most (all?) GeoJSON types.

A quick example

var geojson = {
    "type": "LineString",
    "coordinates": [
        [-80.661983228058659, 35.042968081213758],
        [-80.662076494242413, 35.042749414542243],
        [-80.662196794397431, 35.042626481357232],
        [-80.664238981504525, 35.041175532632963]

var googleOptions = {
    strokeColor: "#FFFF00",
    strokeWeight: 7,
    strokeOpacity: 0.75

googleVector = new GeoJSON(geojson, googleOptions);


See my GeoJSON to Google Maps GitHub repository for “full” documentation and a demo page. I’m sure there’s room for improvement so feel free to fork it and notify me of any changes.