1

我正在尝试使用 wikimapia api 来查找特定城市或地点的地点,因为它们的经度和纬度。没有太多的文档,但我想这只是一个 http 请求。现在,我遇到的问题是关于特定的 ulr。我试过这个:

http://api.wikimapia.org/?function=search
&key= myKey
&q=lat= theLatidute
&lon= theLongitude
&format=json

但它似乎不起作用。任何帮助将不胜感激..

4

1 回答 1

4

搜索 API 要求您设置搜索位置(经纬度)以及要搜索该位置的名称。

例如,要查找特定坐标附近的火车站:

http://api.wikimapia.org/?function=search&key=[key]&q=Train+Station&lat=[latitude]&lon=[longitude]&format=json

如果您只是想查找靠近坐标的对象列表,而没有搜索词,则需要使用带有小偏移量的框 API:

 http://api.wikimapia.org/?function=box&key=[key]&lon_min=[lon_min]&lat_min=[lat_min]&lon_max=[lon_max]&lat_max=[lat_max]&format=json

如果您只想输入一组坐标,您可以像这样计算lon_minlon_max和:lat_minlat_max

// 1 degree latitude is roughly 111km, 0.001 degrees lat is about 100m
var lat_min = latitude - 0.001;
var lat_max = latitude + 0.001;

// 1 degree longitude is not a static value
// it varies in terms of physical distance based on the current latitude
// to compute it in meters, we do cos(latitude) * 111000
var meters_per_longdeg = Math.cos((3.141592 / 180) * latitude) * 111000;

// then we can work out how much longitude constitutes a change of ~100m
var range = 100 / meters_per_longdeg;

var long_min = longitude - range;
var long_max = longitude + range;
于 2011-11-30T19:56:50.977 回答