gpt4 book ai didi

reactjs - react-geocode - 从 lat/lng 获取地址与引用限制 API?

转载 作者:行者123 更新时间:2023-12-03 19:20:16 25 4
gpt4 key购买 nike

我正在尝试使用 react-geocode从他们的 lat/lng 坐标中获取用户的地址,但不幸的是我收到了错误 API keys with referrer restrictions cannot be used with this API.有没有可能得到react-geocode使用允许引荐来源限制的不同 API?否则我将如何去做,因为我无法删除我的 API key 的引用者限制。有没有办法使用我已经用来显示我的 map 的谷歌地图 API 来反转地理编码纬度/经度坐标?

import Geocode from "react-geocode";

Geocode.setApiKey("AIzaSyDsb7F-VyBJn7r4LilYH_lRHBpPfgyUga8");
Geocode.enableDebug();

Geocode.fromLatLng("48.8583701", "2.2922926").then(
response => {
const address = response.results[0].formatted_address;
console.log(address);
},
error => {
console.error(error);
}
);

CodeSandbox

最佳答案

如果你想切换到谷歌地图,他们的(反向)地理编码非常简单。显然,您想要获取 Google Maps API key ( get it here ) 来编写 GET 请求:

 https://maps.googleapis.com/maps/api/geocode/json?latlng=40.714224,-73.961452&key=YOUR_API_KEY

解析结果应该很容易。 :)

资料来源:
  • https://developers.google.com/maps/documentation/geocoding/intro#ReverseGeocoding
  • https://developers.google.com/maps/documentation/geocoding/intro#reverse-example
  • 关于reactjs - react-geocode - 从 lat/lng 获取地址与引用限制 API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59494609/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com