首页 文章

Google商家信息使用地理编码

提问于
浏览
0

我有一个数据库,其中包含有纬度和经度信息的兴趣点列表 . 此数据不是来自Google商家信息 . 我想根据地理位置获取地点开放时间的信息 . 是否可以使用Google Places API执行此操作?

我尝试使用 Google Maps Geocoding API 获取给定地理编码的 place_id ,然后使用 Google Places API Web Service 获取基于 place_id 的地点的详细信息 . 但是,它没有得到开放时间 . 我想知道如何使用地理编码获取地点的细节?

例如,在使用自动填充地点搜索的HERE中,它可以返回有关该地点的详细信息 . 但是,当我右键单击标记并使用 what's this 复制地理位置并尝试使用 Google Places API Web Service 来查询地点的详细信息时,缺少某些信息,例如,打开地点的小时数 .

例如 Gyeongbokgung Palace 存储在数据库中的纬度和经度分别为 37.5802126.977 ,如图所示,即使它们彼此距离不远,谷歌 Map 的位置也不同 .

enter image description here

1 回答

  • 0

    使用Place details,您可以获取特定地点的所有详细信息 .

    function initialize() {
    
        var map = new google.maps.Map(document.getElementById('map-canvas'), {
            center: new google.maps.LatLng(0, 0),
            zoom: 15
        });
    
        var service = new google.maps.places.PlacesService(map);
    
        service.getDetails({
            placeId: 'ChIJod7tSseifDUR9hXHLFNGMIs' // Gyeongbokgung Palace
        }, function (place, status) {
    
            if (status === google.maps.places.PlacesServiceStatus.OK) {
    
                console.log(place); // Log the place object
            }
        });
    }
    

    以下是如何检索您提到的地点的营业时间的完整示例 .

    JSFiddle演示

相关问题