Wasn't it TinyGrasshopper who wrote: >You could also do rough checks to narrow down the possible polygons >the point could be in (and therefore what polygons need to be tested >with the full algorithm) by testing whether the point is within the >bounds of each polygon too (since google provides a function to easily >get the bounds). > >Performance would either go up (if the bounds are all precomputed when >the polygons are loaded) or down (if it has to compute the bounds by >iterating the points) :).
Here's two examples that are identical except that the second one performs bounds checks before performing the polygon test. http://econym.org.uk/gmap/example_states2.htm http://econym.org.uk/gmap/example_states3.htm I compute the bounds once, then store the info as a Property of the polygon. The code checks the states in alphabetical order, and jumps out of the loop when it gets a hit, so clicking on Wyoming shows the biggest speed difference. This code was written before Google introduced clickable polygons. -- http://econym.org.uk/gmap The Blackpool Community Church Javascript Team --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Maps API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/Google-Maps-API?hl=en -~----------~----~----~----~------~----~------~--~---
