Polygon in visible area?

361 views
Skip to first unread message

NoRyb

unread,
Jan 23, 2012, 7:53:48 AM1/23/12
to google-map...@googlegroups.com
Hello

Is it possible to find out, if a polygon is currently in the visible area? So I can get more details from a webservice about an object if it is visible...

Thank you
~N

Andrew Leach

unread,
Jan 23, 2012, 8:50:04 AM1/23/12
to google-map...@googlegroups.com

An easy approximation is to check whether the polygon's bounds
intersects with the map bounds.
http://code.google.com/apis/maps/documentation/javascript/reference.html#LatLngBounds
(scroll down to intersects)

That won't be perfect, but it should provide more data than is
necessary rather than leaving something out which should be retrieved.

NoRyb

unread,
Jan 23, 2012, 9:20:17 AM1/23/12
to google-map...@googlegroups.com, andrew....@gmail.com
how do I get the "LatLngBounds" out of a polygon so I can use intersect?

geoco...@gmail.com

unread,
Jan 23, 2012, 9:53:48 AM1/23/12
to Google Maps JavaScript API v3
On Jan 23, 4:53 am, NoRyb <phrei....@gmail.com> wrote:
> Hello
>
> Is it possible to find out, if a polygon is currently in the visible area?

You mean something like this (warning complex kml rendered in the
browser):
http://www.geocodezip.com/geoxml3_test/v3_geoxml3_ecounties-out_highlightSidebar.html?lat=33&lng=-114&zoom=8

The sidebar is dynamically generated from polygons in the viewport.

-- Larry

NoRyb

unread,
Jan 23, 2012, 10:00:51 AM1/23/12
to google-map...@googlegroups.com
most probably this could hep me. What technique do you use to do this?

thanks!

NoRyb

unread,
Jan 23, 2012, 10:06:48 AM1/23/12
to google-map...@googlegroups.com
oh I see... you create a Bound rectangle for each polygon yourself. That's an option. I hoped there would be something in the API to get that but I will probably do it your way.

Thank you very much.
Reply all
Reply to author
Forward
0 new messages