I have a MySQL database that contains a large number of polygons, one for each district on a map. They are all quite complicated and it's unrealistic to simply load them all at once. I've looked into using MarkerManager for Google Maps API v3 and this seems to be working as intended. However I'm not sure how to best go about querying my database for polygons that are in the viewport.
I'm thinking that it would be best to store the center of each polygon in a separate column as a simple lat,lng pair so that a query could be run on that - and then return the full polygon.
What is the best way to go about this?
SELECT * FROM polygons WHERE [the center of each polygon is within the bounds of the viewport]
Is this even possible? Am I going about this the wrong way?
And additionally, is there a simple script I can run on my data to return the center of each polygon?