如何使用Google Places Javascript API搜索附近(自动从浏览器获取坐标)?

Can Poyrazoglu

我正在开发一个网站,我需要一个文本框,其中预填充了Google地方信息中最近的城市。我目前正在使用自动填充功能来搜索附近的位置,这确实需要浏览器的位置许可,但是我如何使用API​​本身搜索附近的城市,而又不必费心从浏览器获取用户的位置并将其传递给Google Places API调用?由于Google无论如何已经从浏览器获取了我的位置,难道它不应该(从逻辑上)只是搜索相对于我当前位置的附近位置nearbySearch,还是还有其他方法?

Can Poyrazoglu

好的,

我最终从本机获取了位置,然后将位置传递给Places API,因为Places API显然没有这种(非常基本的)功能。这是我的位置信息:

if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(function (position) {
        var pos = {
            lat: position.coords.latitude,
            lng: position.coords.longitude
        };
        //service is a PlacesService instance.
        var req = {
            location: pos,
            radius: '50000',
            types: ['(cities)']
        };

        service.nearbySearch(req, function (results, status) {
           ...
        });
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Google Places附近搜索

来自分类Dev

Google Places Javascript API获得响应状态

来自分类Dev

不带地图的Google Places API库使用-javascript

来自分类Dev

Google Places API的使用

来自分类Dev

Google Maps / Places Javascript API自动补全限制类型

来自分类Dev

NativeScript Google-Places API --> 如何使用?

来自分类Dev

使用Google Places附近搜索API无法获得与Google Places API完全匹配的信息

来自分类Dev

使用php / Wordpress中的Google Places API获取附近的位置

来自分类Dev

如何通过搜索按钮使用Google Places API?

来自分类Dev

如何在iOS Swift中从Google Places API获取坐标

来自分类Dev

使用Google Places API获取google +评论

来自分类Dev

Google Places API,如何获取评论?

来自分类Dev

如何获取自动完成TextView的Google Places API?

来自分类Dev

实施Google Places API

来自分类Dev

Google Places API替代

来自分类Dev

Google Places APi照片

来自分类Dev

Google Places 活动 API

来自分类Dev

使用Google Places API在Google Maps中查找附近的地点

来自分类Dev

从Google Places API获取数据

来自分类Dev

使用Google Places API的Google评论总数

来自分类Dev

Google Places API:了解Places自动完成响应的解析

来自分类Dev

从Symfony Ivory Bundle中的Google Places API获取坐标

来自分类Dev

如何计算Google Maps Places API的配额?

来自分类Dev

Android使用PlaceAutoCompleteActivity(Google Places API)

来自分类Dev

使用Google Places API的最近商店功能

来自分类Dev

Android PlaceFilter与Google Places API的配合使用

来自分类Dev

google Places API使用getPlacePhotos检索照片

来自分类Dev

如何使用jquery或javascript获取浏览器名称?

来自分类Dev

Google places autocomplete api limits

Related 相关文章

热门标签

归档