"Invalid value for property <bounds>" in autocomplete.setBounds()

149 views
Skip to first unread message

fearless_fool

unread,
Jan 30, 2012, 6:42:28 PM1/30/12
to google-map...@googlegroups.com
I've got a perfectly lovely LatLngBounds object:
[bnds.getSouthWest().lat(), bnds.getSouthWest().lng(), bnds.getNorthEast().lat(), bnds.getNorthEast().lng()]
[32.98856751588048, -119.49260720804295, 34.78519808411952, -117.32831699195708]
but when I pass it to
autocomplete.setBounds(bnds);
I'm getting:
Uncaught Error: Invalid value for property <bounds>: ((32.98856751588048, -119.49260720804295), (34.78519808411952, -117.32831699195708))
Any idea why?  Or things I should look for?  (FWIW, when I don't call autocomplete.setBounds(), the autocomplete object is working just fine.)




geoco...@gmail.com

unread,
Jan 30, 2012, 7:35:00 PM1/30/12
to Google Maps JavaScript API v3
On Jan 30, 3:42 pm, fearless_fool <rdp...@gmail.com> wrote:
> I've got a perfectly lovely LatLngBounds object:
> [bnds.getSouthWest().lat(), bnds.getSouthWest().lng(),
> bnds.getNorthEast().lat(), bnds.getNorthEast().lng()]
> [32.98856751588048, -119.49260720804295, 34.78519808411952,
> -117.32831699195708]

Why do you say it is "lovely"? That looks like an array of four
floats, doesn't look like a LatLngBounds object to me.

http://code.google.com/apis/maps/documentation/javascript/reference.html#LatLngBounds

-- Larry

fearless_fool

unread,
Jan 30, 2012, 9:44:22 PM1/30/12
to google-map...@googlegroups.com
You may have misinterpreted my post.  I typed the following into the console to inspect the contents of 'bnds':

[bnds.getSouthWest().lat(), bnds.getSouthWest().lng(), bnds.getNorthEast().lat(), bnds.getNorthEast().lng()]

and it responded (as I expected) with an array of four floats:

=> [32.98856751588048, -119.49260720804295, 34.78519808411952, -117.32831699195708]

From this, I concluded that the bnds object itself appears to be a perfectly valid (and lovely) LatLngBounds object.  I'm at a loss as to why the error message printed it as:

((lat0, lng0), (lat1, lng1))

...but I have no explanation as to how bnds could have been modified between printing it out and being passed to autocomplete.setBounds(bnds).  Am I missing something?

geoco...@gmail.com

unread,
Jan 30, 2012, 10:06:53 PM1/30/12
to Google Maps JavaScript API v3
I have no explanation either (without a link to your map, I have less
information than you do...)

-- Larry

>  Am I missing something?
Reply all
Reply to author
Forward
0 new messages