I do this all the time with sometimes over 3000 polygons containing anywhere from tens to thousands of vertices. If you already have the polygons displayed on the map, make sure that you have an array somewhere that has references to the Google Polygons. Iterate through this list, testing each polygon for the point you are looking for while using the built-in yourPolygon.getLatLngBounds().containsLatLng(myLatLng). However, this lookup will only cover the maximum bounded region (MBR) method.
My implementation is as follows... If you implement a method in flash that uses the winding algorithm, you can find versions of this in many places for many different languages, make sure to test for the MBR first using the method I showed above. If the MBR method shows the point is in the MBR, then continue with the winding algorithm; otherwise, return false and bail. This keeps the method very fast, as you only use the complex winding algorithm for polygons that you are confident *might* contain your point. If your polygons are simple, this can be as easy as just grabbing the outer ring vertices...if they contain holes or multiple shapes, you must search through them making exclusions as necessary. Hope this helps. I use this all the time on thousands of polys, and the lookups are almost instantaneous. - Aaron On May 13, 9:34 am, laxmidi1994 <[email protected]> wrote: > Hi, > > I've got about 129 polygons and 1000s of points. I've built a map that > checks whether the point is in a particular polygon following Google > Maps' actionscript example. Unfortunately, it runs very slowly. I'm > thinking about re-writing the code and doing the point in polygon > check in php. > > Will making the point in polygon check speed things up if I do it in > php? If so, can anyone recommend a point in polygon php script? > > Thanks, > > -Laxmidi > > -- > You received this message because you are subscribed to the Google Groups > "Google Maps API For Flash" 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 > athttp://groups.google.com/group/google-maps-api-for-flash?hl=en. -- You received this message because you are subscribed to the Google Groups "Google Maps API For Flash" 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-for-flash?hl=en.
