我如何修改谷歌地方的自动完成的外观或直接访问JSON并自己做这一切? [英] how can i modify the appearance of google places autocomplete or just access the json directly and do it all myself?

查看:188
本文介绍了我如何修改谷歌地方的自动完成的外观或直接访问JSON并自己做这一切?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:


对于这是否甚至是可能的,似乎存在分歧。我抓住了它从控制台使用的url,但它完全不可编辑,更改回调会导致错误。

示例: https://maps.googleapis.com/maps/api/js/AutocompletionService.GetPredictions?1sgoo&4sen-US&5sUS&9sestablishment&callback = xdc ._ y53chi& token = 28177

这是有效的(发布时),但任何改变都会导致它破坏。如果我可以控制回调或让jQuery修改回调以用于jsonp,我将被设置。任何想法?

解决方案

有两种方式可以访问Google Maps Autocomplete API。



第一个是通过 google.maps.places.Autocomplete 类。这提供了所有必要的Javascript实现。但是,您可以完全控制造型。使用 pac-container pac-item CSS类。



第二个是通过自动填充网络服务。由于同源策略(没有JSONP API),因此无法通过浏览器访问。这是访问自动填充结果的最灵活方式。


Possible Duplicate:
Can Google Maps/Places 'autocomplete' API be used via AJAX?

There seems to be disagreement about whether or not this is even possible. I grabbed the url that its using from console but it is totally un-editable, changing the callback causes an error.

Example: https://maps.googleapis.com/maps/api/js/AutocompletionService.GetPredictions?1sgoo&4sen-US&5sUS&9sestablishment&callback=xdc._y53chi&token=28177

That works (at time of posting) but changing anything causes it to break. If I could control the callback or let jQuery modify the callback for use with jsonp I'd be set. Any ideas?

解决方案

There are two ways to access the Google Maps Autocomplete API.

The first is via the google.maps.places.Autocomplete class. This provides all the necessary implementation in Javascript. However, you have complete control over styling. Use the pac-container and pac-item CSS classes.

The second is via the Autocomplete Web Service. This is not accessible via the browser because of same origin policy (there is no JSONP API). This is the most flexible way to access Autocomplete results.

这篇关于我如何修改谷歌地方的自动完成的外观或直接访问JSON并自己做这一切?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆