On Nov 15, 5:39 pm, CroNiX <
cronix...@gmail.com> wrote:
> Is there a more efficient way to detect if any part of a polygon is in
> the current map bounds than to cycle through the polygons' points and
> manually test each point or is there a better way? I did not see a
> native way to test a polygon like you can with a point using
> contains(). The docs say contains() requires a single latLng object
> as the parameter. Its too bad it can't test whether the parameter is
> an array and do the same as below if it was, at least it doesn't seem
> so from the docs....
>
> I am currently doing this for my polygon detection, which works very
> well but looks like it can eat some horsepower if used on complex
> polygons, especially if tied to the bounds_changed event.
>
> function isPolyInBounds(map, polygon) { //map obj, polygon obj
> var currentBounds = map.getBounds();
> var polyPoints = polygon.getPath(); //get path of current polygon
> var inBounds = false; //this will be set to true if at least 1
> point is in the current bounds
>
>