0
votes

I'm building an interactive map of US states and Canadian provinces. I have a working copy here: http://www.willoughby-ind.com/FINDAREP.aspx. It's fully functional and does all I want it to. You can tell I got the US from one source and CA from another. The US data source was hand drawn and is good enough for my needs. The Canadian data source is very accurate as it came from an official source, but it's so accurate it's also slow to load. I'd like to hand draw my own GPS coordinates and download the coordinate data so that I can put it into the format Google Maps can import.

Google has this demo of how to create your own polygons: http://googlemapsapi.blogspot.com/2008/05/love-my-maps-use-its-line-and-shape.html. I'd like to see if I can easily extend that to download the list of coordinates in the selected polygon. Has anyone seen this already in existence, or do I need to interact with the API myself?

3

3 Answers

2
votes
  1. You are using the Google Maps API v2, that is deprecated and may stop working as early as May 2013.
  2. You are parsing the polygons in the client. You may get better performance by converting the polygons to KML and loading them using KmlLayer or importing the KML into FusionTables and loading them using FusionTablesLayer. Both KmlLayer and FusionTablesLayer are rendered as tiles served from Google's servers. FusionTables contains the Natural Earth data set in a public table, that data set contains both US and Canadian state/province polygons:

USA

Canada

1
votes

You can either load your Canadian data into a spatial database, (such as PostgreSQL/PostGIS), and simplify the polygons, or you can plot them on custom tiles for fast loading, like this.

If you use custom tiles then you'd attach the click event listener to the map itself and send the lat/lon of the click to the server in an AJAX call to look it up in the database and determine which polygon was clicked.

1
votes

Here's a tool someone built which does many things. If you select the 'Polygon' option, then draw your polygon, it outputs the KML of all the coordinates:

http://www.birdtheme.org/useful/v3tool.html

Also if you're using API v2, they have an older version that does the same thing:

http://www.birdtheme.org/useful/googletool.html

However strongly agree with geocodezip's comment about upgrading to API v3.