determine if lat / lng within boundaries of routeBoxer

278 views
Skip to first unread message

Steven Rhodes

unread,
Dec 22, 2010, 11:25:06 PM12/22/10
to Google Maps JavaScript API v3
Ok.

Thanks to @Rossko I have looked at <a href="http://www.google.com/url?
sa=D&q=http://groups.google.com/group/google-maps-js-api-v3/
browse_thread/thread/1035dd98bfa0c9db/
2d001f38e5c17dfa&usg=AFQjCNFR9Bqc9L7kcxFZaxlnhKL1888ucw">RouteBoxer</
a> as recommended.

My next question is what would be the appropriate manner, or
terminology I need to look at, to determine if the latitude /
longitudes I have stored in my database fall within the boundaries of
these boxes?

Thank you for your patience as I learn...

Steven

Steven Rhodes

unread,
Dec 23, 2010, 1:40:19 PM12/23/10
to Google Maps JavaScript API v3
I have found that the RouteBoxer will only return the lat / lng of the
opposing corners of each grid drawn on the map.

So, if I was to use a "Bounding Box" to determine if the locations in
my database are within the Bounding Box I would need the other two
corners that are no provided.

How would I go about retrieving the missing corners of the boxes
created by RouteBoxer?

Sorry to ask such basic questions, please understand I am learning
several new concepts as quickly as possible.

Thank you.
Steven

geoco...@gmail.com

unread,
Dec 23, 2010, 1:49:08 PM12/23/10
to Google Maps JavaScript API v3
On Dec 23, 10:40 am, Steven Rhodes <k7faq...@gmail.com> wrote:
> I have found that the RouteBoxer will only return the lat / lng of the
> opposing corners of each grid drawn on the map.
>
> So, if I was to use a "Bounding Box" to determine if the locations in
> my database are within the Bounding Box I would need the other two
> corners that are no provided.
>
> How would I go about retrieving the missing corners of the boxes
> created by RouteBoxer?

A google.maps.LatLngBounds contains:
http://code.google.com/apis/maps/documentation/javascript/reference.html#LatLngBounds
SW and NE corners. Knowing it is a box, you can construct the
missing 2 corners from those (if you need them).

However, a google.maps.LatLngBounds also has this need method:
contains(latLng:LatLng)
boolean
Returns true if the given lat/lng is in this bounds.

Which will let you determine if your LatLng is within it.

-- Larry

Rossko

unread,
Dec 23, 2010, 2:32:13 PM12/23/10
to Google Maps JavaScript API v3
> So, if I was to use a "Bounding Box" to determine if the locations in
> my database are within the Bounding Box I would need the other two
> corners that are no provided.

It's easy to work that out if you remember it only takes two corners
to define a box ; you can extract the w part of sw and the n part of
ne - and put them together to yield nw

However, for finding database records contaned within a given box its
only arithmetic requiring the n s e w components ...
SELECT ... WHERE lat > s AND lat < n AND long > w ....

If your searches might go near the 180/-180 antimeridian you need to
expand that a bit to test for a box crossing the 180/-180 boundary and
split into two. That is easier than it sounds, but may not be needed
at all in many "single country" use cases.

Steven Rhodes

unread,
Dec 23, 2010, 2:38:19 PM12/23/10
to Google Maps JavaScript API v3
Thank you Larry! I will look at this.

Steven

On Dec 23, 11:49 am, "geocode...@gmail.com" <geocode...@gmail.com>
wrote:
> On Dec 23, 10:40 am, Steven Rhodes <k7faq...@gmail.com> wrote:
>
> > I have found that the RouteBoxer will only return the lat / lng of the
> > opposing corners of each grid drawn on the map.
>
> > So, if I was to use a "Bounding Box" to determine if the locations in
> > my database are within the Bounding Box I would need the other two
> > corners that are no provided.
>
> > How would I go about retrieving the missing corners of the boxes
> > created by RouteBoxer?
>
> A google.maps.LatLngBounds contains:http://code.google.com/apis/maps/documentation/javascript/reference.h...
Reply all
Reply to author
Forward
Message has been deleted
0 new messages