results[0].geometry.bounds is not always defined - bounds is returned if it
is applicable.

You should instead check to see that .bounds exists before you try to use it
and if it doesn't - try to  call contains() and pass
in results[0].geometry.location if that exists too.

-- Luke


On Mon, May 16, 2011 at 9:11 AM, Draiken <[email protected]> wrote:

> Found a place to host the code.
>
> http://jsfiddle.net/EjKTh/
>
> I really don't know what is wrong...
>
> Sorry about the typos, I'm in a real hurry to get this working.
>
> On May 16, 12:49 pm, Draiken <[email protected]> wrote:
> > Okay, silly mistake about the contains, made sense to me it would
> > accept a LatLngBounds but it accepts only a LatLng
> >
> > But now I managed to prove the error with the intersects()
> >
> > Was trying to add a map with the script so people could see the error,
> > but don't have anywhere to place it.
> >
> > basically making a GeocoderRequest with:
> >   geocoder.geocode({
> >     address : 'getúlio',
> >     bounds  : map.getBounds()
> >     language: 'pt_BR'
> >   });
> >
> > and then check the result with the intersects
> >
> >   mapBounds.intersect(results[0].geometry.bounds); // returns false
> >
> > why is that?
> >
> > On May 16, 11:22 am, Draiken <[email protected]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > Hi, I am trying to restrict the search from the geocoder to a certain
> > > LatLngBounds
> >
> > > I am getting two strange behaviours:
> >
> > > 1 - When positioning the center in
> > >       Lat: -25.42777778
> > >       Lng: -49.27305556
> > >       Zoom: 12
> > >     Then  searching "getúlio" in geocoder address within the bounds of
> > > that map
> >
> > > I get the result off a place WAY out of the bounds I set on the
> > > geocoder request
> >
> > > 2 - To check that, I tried to use the contains() method over the two
> > > bounds and got an error:
> > >       map.getBounds().containts( results[0].geometry.bounds );
> >
> > > I get the error:
> > >       a.lat is not a function on line 15
> >
> > > I've checked and both the map.getBounds() and the
> > > results[0].geometry.bounds do return correct bounds
> >
> > > If the bounds passed on the GeocoderRequest are not meant to restrict
> > > results for that area, I don't know what is the function of that.
> >
> > > Please any help is appreciated.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Maps JavaScript API v3" 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-js-api-v3?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" 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-js-api-v3?hl=en.

Reply via email to