Places webservice jsonp issue

1547 views
Skip to first unread message

Asif Maniar

unread,
May 18, 2011, 3:47:47 PM5/18/11
to google-maps-ap...@googlegroups.com
Am trying to use the Google Places webservice to build an auto-complete textbox.
I can use the JavaScript API but since the API doesn't use the API key any entries added from my app aren't visible if I use the JavaScript API.

Am using jQuery jsonp request to do a GET:
 $.ajax(
                        {
                            url: 'https://maps.googleapis.com/maps/api/place/autocomplete/json?callback=?',
                            data: { 'key': apiKey, 'location': location, 'radius': radius,
                                'sensor': sensor, 'input': term, 'types': 'establishment', 'region': 'IN'
                            },
                            dataType: 'jsonp',
                            crossDomain : true,
                            type: 'GET',
                            success: successFunc,
                            complete: completeFunc,
                            error: errorFunc,
                            dataFilter: dataFilterFunc
                        });

Instead of calling the callback the service seems to return valid json so am getting parse exceptions in my JavaScript and the success is never called.
I see the correct results in firebug.

Is there a way to use the web-service directly from JavaScript?

Chris Broadfoot

unread,
May 18, 2011, 6:40:25 PM5/18/11
to google-maps-ap...@googlegroups.com
We don't provide a JSONP interface for Autocomplete.

Have you tried using this?


Chris

--
You received this message because you are subscribed to the Google Groups "Google Maps API Web Services" group.
To post to this group, send email to google-maps-ap...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-api-web-...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-api-web-services?hl=en.



--
http://twitter.com/broady

Asif

unread,
May 19, 2011, 11:22:14 AM5/19/11
to Google Maps API Web Services
Hi Chris,
Yes I looked into the Autocomplete JS package.
It works great but since it doesn't use my API key I wont be able to
get the places added by my application until they are approved. Right?

Is there any other way or should I be calling back to my server and
then making a call to the Google web-service using my API key for
autocomplete and search? Wanted to keep it purely client side but if
there is no other option will write some server side services.

Thanks for your help.

Asif


On May 18, 6:40 pm, Chris Broadfoot <c...@google.com> wrote:
> We don't provide a JSONP interface for Autocomplete.
>
> Have you tried using this?
>
> http://code.google.com/apis/maps/documentation/javascript/reference.h...

hemm

unread,
May 25, 2011, 1:58:47 PM5/25/11
to google-maps-ap...@googlegroups.com
According to the Places docs, a map is no longer needed to use the web service as long as you provide attribution to Google.  That being the case, how would one call the web service via JavaScript without using JSONP (given the cross-domain issues when not using JSONP).

If a map is not being utilized, is the only option to do a server-side call to the web service?

Barry Hunter

unread,
May 25, 2011, 2:41:24 PM5/25/11
to google-maps-ap...@googlegroups.com

Well you can load the Maps API and the places library, and use it to
provide auto-complete.

Just dont use it to display an actual map.

As noted you will still have to make sure attribution is displayed.

Sarah Woenne

unread,
May 25, 2011, 7:55:29 PM5/25/11
to google-maps-ap...@googlegroups.com
Hi hemm,

To clarify, it is necessary to have a corresponding Google map when you use the Places API (see clause 10.1.1(g) of the Terms of Service).  However, the map need not be always visible in your application - for example, it's fine to have Places data displayed on a map in one tab, and Places data displayed in a list in another tab.  In that case, you would need to put the 'Powered by Google' logo in the tab with the list, because the Google map is not visible.

Hope this helps,

Sarah

David Trallero

unread,
Jun 2, 2011, 7:45:26 PM6/2/11
to google-maps-ap...@googlegroups.com

We don't provide a JSONP interface for Autocomplete.

Have you tried using this?


I am having the same issues when using Places Autocomplete. I am afraid that I will have to
use the autocomplete "class" provided by maps library API. My current problem is that I want
slightly different output representation than the one offered by the autocomplete. Is it possible
to have a callback to "prettify"  the elements content/style? (as I guess not) is there any plan
for this?

thanks,
  David

Asif Maniar

unread,
Jun 3, 2011, 12:45:31 PM6/3/11
to google-maps-ap...@googlegroups.com
Yep that's what am using now. Wanted to see if its possible for places added by my app to also appear in the auto-complete but I guess its not possible.

Thanks for your help.

--
You received this message because you are subscribed to the Google Groups "Google Maps API Web Services" group.
Reply all
Reply to author
Forward
0 new messages