地理位置问题,一旦给出结果,其他所有超时

时间:2019-03-06 06:07:12

标签: node.js google-maps

我安装了https://github.com/googlemaps/google-maps-services-js

我连接了import maps from '@google/maps';

我创建了一个客户端:

const googleMapsClient = maps.createClient({
    key: 'api key',
});

我想获得经度和纬度:

router.post('/add', (req, res) => {
    googleMapsClient.geocode({
        address: '1600 Amphitheatre Parkway, Mountain View, CA'
    }, (err, res) => {
        if (!err) {
            console.log(res.json.results);
            return res.status(500).json({
                message: res.json.results
            });
        }
        console.log(err);
        return res.status(500).json({
            err: err
        });
    });
    ...

我的问题是他第一次提供信息

[ { address_components:
     [ [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object],
       [Object] ],
    formatted_address: '1600 Amphitheatre Pkwy, Mountain View, CA 94043, USA',
    geometry:
     { location: [Object],
       location_type: 'ROOFTOP',
       viewport: [Object] },
    place_id: 'ChIJhhRjJ-5j4ARKFsUSrwhY',
    plus_code:
     { compound_code: 'CWC8+JH Mountain View, California, United States',
       global_code: '849VCWC8+JH' },
    types: [ 'street_address' ] } ]

他下次再给我

timeout

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

如果您的项目未启用计费功能,则您的Maps Platform API每天最多只能请求1个请求。通过为您的项目启用结算功能,可以获得更高的配额。

Google Maps Docs