gpt4 book ai didi

java - 从 google map api 检索坐标

转载 作者:行者123 更新时间:2023-12-01 06:58:07 26 4
gpt4 key购买 nike

我有一个地址列表,我现在想检索它们的经度和纬度。我想通过java使用谷歌地图API。我将如何检索一个地址的一组坐标。 (因为我可以轻松实现多个)

最佳答案

您还可以使用 Google Geocoder Java API GeoGoogle像这样:

// Initialize a new GeoAddressStandardizer-class with your API-Key
GeoAddressStandardizer st = new GeoAddressStandardizer(apikey);
// Get a list of possible matching addresses
List<GeoAddress> addresses = st.standardizeToGeoAddresses(address);
// Get the first address (like you posted above)
GeoAddress address = addresses.get(0);
// Get the coordinates for the address
GeoCoordinate coords = address.getCoordinate();
// Longitude
double longitude = coords.getLongitude();
// Latitude
double latitude = coords.getLatitude();

关于java - 从 google map api 检索坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6236017/

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