我安装了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
我该如何解决这个问题?
答案 0 :(得分:1)
如果您的项目未启用计费功能,则您的Maps Platform API每天最多只能请求1个请求。通过为您的项目启用结算功能,可以获得更高的配额。