首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >仅获取给定一个纬度和一个经度的矩形四点

仅获取给定一个纬度和一个经度的矩形四点
EN

Stack Overflow用户
提问于 2011-04-16 21:44:34
回答 2查看 2.3K关注 0票数 1

我正在阅读这个: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

但通常我们只得到一个纬度点和一个经度点。

我应该写什么样的表达式来构建上面提到的四个点,以覆盖我手中有两个点的区域周围的图片?

例如,我在巴黎有:

更新:48.8566667

液化天然气:2.3509871

我想要覆盖它周围的图片10公里的矩形。

谢谢。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-08-20 00:12:57

这是我从Panoramio Forum by QuentinUK得到的答案。

不能做10公里的距离,因为这意味着一个圆形区域。它只能做矩形。

所以你可以近似(最好是使用Vincenty的公式),并计算该点周围的角度+/-。

代码语言:javascript
复制
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
EN

Stack Overflow用户

发布于 2013-03-06 07:23:11

如果您想使用REST api:

var纬度= "48.8566667";var经度= "2.3509871";

变角= km * 0.0089833458;

代码语言:javascript
复制
        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>";
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5686887

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档