- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我需要从包围地面叠加层的矩形中获取 NW LatLng。使用 mOverlay.getBounds() 将使我在旋转之前得到我需要的点(getBounds 忽略旋转)。
这是地面叠加层,我需要的确切 LatLng 是红色点。当它完全位于北/南(左图)时,我可以使用 getBounds() 毫无问题地得到这个点。旋转图像后,我现在需要任何点,即包含我旋转的地面叠加层的北/南面矩形的 NW 角(右侧图像的红点)。
最佳答案
我不得不假设您正在使用“方位角”来旋转叠加图像并且图像的 anchor 是中心。此外,由于 map 是一个球体模型,当你说矩形时,我们实际上假设一个二维平面与图像中心的球体相切(未旋转)。
这个解释做了一个简化的假设,即旋转角度小于 pi/2 弧度,并且是顺时针方向。
这些都不是新的,所以没有功劳 - 但我尽力适应你的问题。
总而言之,此方法将 WGS-84 坐标系中的原始矩形(未旋转)转换为 x/y 坐标系(以原点为中心),计算旋转后的新 x/y,使用 trig 选择角,导出 x/y 超矩形的左上角并将结果转换回WGS-84球坐标系。
// convert your rotation value (bearing clockwise) to radians
// Using the bounding rectangle (which is of the non-rotated image) compute distance
// between nw and ne corner (width) and nw and sw corner (height) (in meters).
// The purpose of this is to establish an x/y coordinate system with origin being
// the center of the non-rotated image.
// Compute the corner coordinates of original bounding rectangle in an x/y coordinate
// system using the center as the origin (0,0) e.g. divide NW-NE width by 2 change sign as needed. Units are meters
// Compute rotated NW corner (x`,y`) (in x/y system) using original NW corner(x/y)
// and bearing:
// x` = x * cos(bearingInRadians) + y * sin(bearingInRadians) and y` = -(x * sin(bearingInRadians)) + y * cos(bearingInRadians)
// Compute the y-distance from original NW corner (x/y) to new NW corner (x`,y`)
// (subtract the y's)
// Compute latitude of super-bounding by using SphericalUtil.computeOffset using
// original NW lat-lng as 'from', and y-distance (meters) as distance and heading as 0 (north-up).
// Compute the rotated SW corner(x``,y``) (in x/y system) in the same manner
// as the NW corner above.
// Compute the x-distance from original SW corner (x/y) to new SW corner
// Compute longitude of super-bounding rectangle by using
// SphericalUtil.computeOffset using original NW lat-lng as 'from', and
// x-distance (meters) as distance and heading as 270.
克服简化意味着选择要使用的正确角点,并将其映射到纬度和经度。
我希望类似的东西已经实现,但希望这有助于解释需要什么。快乐狩猎。
下面是上面的实现:
GroundOverlayOptions goo = new GroundOverlayOptions();
BitmapDescriptor bd = BitmapDescriptorFactory.fromResource(R.drawable.rectangle);
goo.image(bd);
goo.position(latLng, 1000F);
GroundOverlay go = mMap.addGroundOverlay(goo);
LatLngBounds llb = go.getBounds();
LatLng ne = llb.northeast;
LatLng sw = llb.southwest;
PolylineOptions po = new PolylineOptions().add(new LatLng(llb.northeast.latitude,llb.southwest.longitude))
.add(llb.northeast)
.add(new LatLng(llb.southwest.latitude,llb.northeast.longitude))
.add(llb.southwest)
.add(new LatLng(llb.northeast.latitude,llb.southwest.longitude));
Polyline polyline = mMap.addPolyline(po);
MarkerOptions mo = new MarkerOptions();
mo.position(new LatLng(ne.latitude,sw.longitude));
mMap.addMarker(mo);
goo.bearing(25.0F);
GroundOverlay go2 = mMap.addGroundOverlay(goo);
double rads = Math.toRadians(25.0);
float[] result = new float[1];
Location.distanceBetween(llb.northeast.latitude, llb.southwest.longitude, llb.northeast.latitude, llb.northeast.longitude, result);
float width = result[0];
Location.distanceBetween(llb.northeast.latitude, llb.northeast.longitude, llb.southwest.latitude, llb.northeast.longitude, result);
float height = result[0];
float upperLeftX = -(width / 2);
float upperLeftY = (height / 2);
float lowerLeftX = upperLeftX;
float lowerLeftY = -upperLeftY;
double newX = (upperLeftX * cos(rads) + upperLeftY * sin(rads));
double newY = (-(upperLeftX * sin(rads)) + upperLeftY * cos(rads));
double deltaY = abs(newY - upperLeftY);
LatLng newLat = SphericalUtil.computeOffset(llb.northeast, deltaY, 0.0);
double newX2 = (lowerLeftX * cos(rads) + lowerLeftY * sin(rads));
double newY2 = (lowerLeftX * Math.sin(rads) + lowerLeftY * cos(rads));
double deltaX = abs(newX2 - lowerLeftX);
LatLng newLng = SphericalUtil.computeOffset(llb.southwest, deltaX, 270.0);
MarkerOptions mo2 = new MarkerOptions();
mo2.position(new LatLng(newLat.latitude, newLng.longitude));
mMap.addMarker(mo2);
结果:
注释
引用资料:
关于android - 旋转后从地面叠加层获取 NW LatLng,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48895334/
有人有 DirectDraw 叠加的工作示例(代码)吗?就像屏幕上移动的东西一样。我一直试图找到 DirectDraw 叠加用法的示例,但未能找到。 谢谢。 最佳答案 尝试其中一些: from gam
我在 JPanel 中显示缩略图。当将鼠标悬停在此类缩略图上时,我想在缩略图上方的叠加层中显示其完整版本。 使用 HTML,我只需创建一个具有适当位置和高 z-index 的 div,以便它覆盖其他所
好的,所以我想做一个覆盖屏幕。 因此,每当按键为 p 时,屏幕就会暂停并弹出一个屏幕,显示:“按‘q’退出或按‘c’继续,”类似的事情。 谁能告诉我怎么做? 最佳答案 最简单的方法是使用子模块,然后为
查看我的代码: id mapped! DisplayName (user defined) mapped! Pr
我想为 QListWidget 或 QWidget 等小部件分配背景图像。这是想法: 理想情况下,背景图像会在其小部件大小发生变化时调整大小。有什么想法如何实现它吗? 稍后编辑: 这是对话的屏幕截图,
我正在尝试设置一个授权方案,我在其中检查 1. 用户已登录 2. 用户有权访问某个对象。为此,我首先调用 maybeAuthId ,然后尝试获取当前对象,并“加入”到另一个列出权限的表。有两个级别的可
我想绘制两个系列的十个 fiddle 图,一个超过第二个: library(ggplot2) #generate some data coco1<-rnorm(10000,0,1) coco2<-c(
有谁知道如何触发在网格加载时显示的股票 jqGrid“正在加载...”叠加层?我知道我可以毫不费力地使用 jquery 插件,但我希望能够使我的应用程序的外观与 jqGrid 中已经使用的外观保持一致
我正在尝试在我的谷歌地图上实现“负”覆盖,类似于您在estately.com上获得的效果。基本上,我已经根据收集的 KML 数据成功绘制了 map 多边形。当有多个路径时,它们绘制得很好。 因此,对我
您好,我正在制作一个 Android 应用程序,它使用地理位置/Google map ,除了选项卡主机之外, map /应用程序上没有任何按钮。所以我需要它,所以如果用户点击 1500 毫秒,就会出现
我正在尝试叠加两个不同的 map ,但我无法叠加它们,并且我不知道如何解决此问题。 let bottom_left = ol.proj.fromLonLat([5.00975294202035
jquery 不是最好的,有人可以建议一个通用的方法来实现我想要实现的目标吗?我有一个照片网格,当它们被点击时,一个不透明的覆盖层将在整个图片之上动画化,覆盖层将包含一些动态设置的文本。我有图像和 o
我想问一下如何为我的 android 应用程序添加不同的叠加层?因为我已经有一个扩展 Overlay 的覆盖类,它根据 KML 文件中的某些点绘制多段线。现在我想创建另一个叠加层,使用 GPS 在用户
我目前正在使用谷歌地图并且是新手..我想知道是否可以将 map 划分为具有确定高度和宽度的某些 tiles 并为它们 color ..如果是,那么有人可以解释如何去做因为我面临困难。 最佳答案 我认为
我有一个用于在我的 MapView 上绘制路径的叠加层,但我注意到它每秒被不必要地重绘大约十次。由于在 draw 方法中我绘制了路径的每一段,这很容易成为效率问题。 出于这个原因,我决定缓存叠加层的内
我是 AR 的新手。但我对我想做什么有一个大概的想法。 我想在 Android 中将 UI 元素叠加在相机输入之上。 这些 UI 元素将根据陀螺仪、gps 输入、通过蓝牙、wifi 等实时更新。 类似
我有一个带有 .xib 的 UICollectionViewCell。 这是 xib 文件的结构 您可以看到同一级别的每个元素以及 3 个 ImageView 和一个按钮。但在运行时,这些元素前面有一
我有一个关于在哪里存储 map 覆盖的大图像的问题。 图片约100MB,不能缩小或在线存储(要求)。我一直在考虑使用 Assets 目录(xcassets),但它似乎适用于在不同设备上需要调整大小的图
我的应用程序的 css 覆盖了 SmartGWT 中的一些样式并真正降低其性能。 如果我使用 css 文件运行我的应用程序,它太慢了,我什至无法将鼠标悬停在 ListGrid 小部件上。但是,如果我取
我正在制作一个网页,但遇到了问题。当屏幕为 980 像素或更小时,菜单会自行隐藏,屏幕上会出现类似“汉堡包”的按钮菜单。当您单击该按钮时,一个 div 会占据整个屏幕并显示菜单(效果很好)。但是,当您
我是一名优秀的程序员,十分优秀!