如何使用 HERE API 从纬度和经度获取北东南和西值?

How to get north south east and west values from latitude and longitude using HERE API?

在此处使用此 API: https://geocoder.api.here.com/6.2/geocode.json?searchtext=200%20S%20Lodhi%20Colony%20CA&app_id=***&app_code=#### 我能够获得有关 Lodhi Colony 的所有信息。同样,我想将输入作为纬度和经度传递,并希望它是南北和东西值。

示例:

输入:

纬度 = 41.02633002010979 长 = -111.94550019690477

输出: "mapView":{ "west": 2.33073, "south": 48.86836, "east": 2.33347, "north":48.87016 }

我尝试使用此处提供的信息(https://developer.here.com/c/geocoding),但无法使用。

**编辑:** 我想要给定纬度和经度的边界框。

请参考下面的示例以使用地理编码 API 来了解边界框的细节。 通过mapview参数,可以适当的赋值x,y,在地图上形成一个方框。

https://developer.here.com/documentation/examples/rest/geocoder/latitude-longitude-by-mapview-parameter

在其他堆栈溢出答案的帮助下,我自己弄明白了,不需要任何 API。

import math
latitude = 41.02633002010979
longitude = -111.94550019690477
offset = 1.0 / 1000.0;
latMax = latitude + offset
latMin = latitude - offset

lngOffset = offset * math.cos(latitude * math.pi / 180.0)
lngMax = longitude + lngOffset
lngMin = longitude - lngOffset

print("latMax = "+str(latMax), "latMin = "+str(latMin), "lngMax = "+str(lngMax), "lngMin = "+str(lngMin) )