我正在阅读此内容:http://www.panoramio.com/api/widget/api.html#photo-widget以构建JavaScript照片小部件。
在Request
下 - > request object
表,写成:
名称:rect
示例值:{'sw': {'lat': -30, 'lng': 10.5}, 'ne': {'lat': 50.5, 'lng': 30}}
意思是:This option is only valid for requests where you do not use the ids option. It indicates that only photos that are in a certain area are to be shown. The area is given as a latitude-longitude rectangle, with sw at the south-west corner and ne at the north-east corner. Each corner has a lat field for the latitude, in degrees, and a lng field for the longitude, in degrees. Northern latitudes and eastern longitudes are positive, and southern latitudes and western longitudes are negative. Note that the south-west corner may be more "eastern" than the north-east corner if the selected rectangle crosses the 180° meridian
但通常我们只给出一个纬度点和一个经度点。
我应该用什么样的表达方式来构建上面提到的四个点,以覆盖我手边有两点的区域周围的图片?
例如,我在巴黎:
lat:48.8566667
lng:2.3509871
我想要覆盖10公里左右的图片。
感谢。
答案 0 :(得分:1)
以下是QuentinUK从Panoramio Forum得到的答案。
不能做10公里的距离,因为这意味着一个圆形区域。它只能做矩形。
所以你也可以近似(最好使用Vincenty的公式)并计算一个角度+/-。
function requestAroundLatLong(lat,lng,km){
// angle per km = 360 / (2 * pi * 6378) = 0.0089833458
var angle=km* 0.0089833458;
var myRequest = new panoramio.PhotoRequest({
'rect': {'sw': {'lat': lat-angle, 'lng': lng-angle}, 'ne': {'lat': lat+angle, 'lng': lng+angle}}
});
return myRequest;
}
var widget = new panoramio.PhotoWidget('wapiblock', requestAroundLatLong(48.8566667, 2.3509871,10), myOptions);
答案 1 :(得分:1)
如果您想使用REST api:
var Lattitude =“48.8566667”; var Longitude =“2.3509871”;
var angle = km * 0.0089833458;
testo.Text = "<script src=\"http://www.panoramio.com/map/get_panoramas.php?order=popularity&set=full&from=0&to=14&minx=" + clon - angle + "&miny=" + clat - angle + "&maxx=" + clon + angle + "&maxy=" + clat + angle + "&callback=mostrareFotos&size=medium\" type=\"text/javascript\"></script>";