places_autocomplete.html example => example "google is not defined"

339 views
Skip to first unread message

fearless_fool

unread,
Jan 29, 2012, 5:20:48 PM1/29/12
to google-map...@googlegroups.com
I want to build upon the example code found in:


It works fine from the above URL, but when I copy the source code and past it into a local file, opening the local file results in a javascript console error:

    "Uncaught ReferenceError: google is not defined"

... and the input form doesn't autocomplete, etc.  Sure enough, when I look at the source, I see references to 'google' but no definition. What am I missing?

geoco...@gmail.com

unread,
Jan 29, 2012, 7:31:06 PM1/29/12
to Google Maps JavaScript API v3
On Jan 29, 2:20 pm, fearless_fool <rdp...@gmail.com> wrote:
> I want to build upon the example code found in:
>
> http://code.google.com/apis/maps/documentation/javascript/examples/pl...
>
> It works fine from the above URL, but when I copy the source code and past
> it into a local file, opening the local file results in a javascript
> console error:
>
>     "Uncaught ReferenceError: google is not defined"
>
> ... and the input form doesn't autocomplete, etc.  Sure enough, when I look
> at the source, I see references to 'google' but no definition. What am I
> missing?

A valid reference to the API.

This (from that example):
//maps.googleapis.com/maps/api/js?sensor=false&libraries=places

won't work. See the documentation:
http://code.google.com/apis/maps/documentation/javascript/tutorial.html#Loading_the_Maps_API

-- Larry

Chris Broadfoot

unread,
Jan 29, 2012, 8:17:05 PM1/29/12
to google-map...@googlegroups.com
To add to what Larry said, the "//" is known as a "protocol relative URL". This won't work on file://, unfortunately.

--
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 google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.


Robert Poor

unread,
Jan 29, 2012, 8:25:04 PM1/29/12
to google-map...@googlegroups.com
On Sun, Jan 29, 2012 at 17:17, Chris Broadfoot <cb...@google.com> wrote:
> To add to what Larry said, the "//" is known as a "protocol relative URL".
> This won't work on file://, unfortunately.

That was it. (After Larry's comment, I thought it was the lack of the
API_KEY, but it was actually the lack of the http: prefix.)

Thanks, all!

Reply all
Reply to author
Forward
0 new messages