如何在图像上绘制(显示)用户位置? iOS版

时间:2022-11-15 19:57:14

So here is task i need to get done on iOS:

所以这是我需要在iOS上完成的任务:

Show User's Current Location on an Image like this:

在图像上显示用户的当前位置,如下所示:

如何在图像上绘制(显示)用户位置? iOS版

Yes, like this Image!

是的,就像这张图片!

So few things one will notice as soon as one look at it. Its Tilted. It's headings are Off. You can see horizon..!

一看一眼就会注意到的事情很少。它的倾斜。它的标题是关闭。你可以看到地平线..!

Lets say,

让我们说,

  • I have location coordinates for corners of this image.
  • 我有这个图像角落的位置坐标。
  • I have angle at which this image is tilted. (e.g 50°)
  • 我有这个图像倾斜的角度。 (例如50°)
  • I have heading angle of the image. (e.g -170° North, which means its about 10° South-West, correct me if im wrong.)
  • 我有图像的标题角度。 (例如,北纬170°,这意味着它大约10°西南,如果我错了,请纠正我。)
  • And i have Zoom level on which this image would have been zoomed if it was on Google Maps/Google Earth. (e.g 14 zoom level - out of 20)
  • 我有缩放级别,如果它在谷歌地图/谷歌地球上,这个图像将被缩放。 (例如14个缩放级别 - 20个)

But thats the task, i need to show users location on such images. Just like in "Google Earth".

但那就是任务,我需要在这些图像上显示用户位置。就像在“谷歌地球”中一样。

Can anyone give me heads up to accomplish this task?

任何人都可以帮我完成这项任务吗?

Thank you everyone. :)

谢谢大家。 :)

2 个解决方案

#1


1  

Given the information you have, sounds like you can use line-plane intersection to solve your problem.

根据您拥有的信息,听起来您可以使用线平面交叉点来解决您的问题。

#2


0  

I achieved the desired result by plotting the coordinate on a UIView and transform it using CATrasnform3D. These explanations also help, Explanation of Transformation Matrix in terms of Core Animation and Core Animation Programming Guide itself.

我通过在UIView上绘制坐标并使用CATrasnform3D对其进行转换来实现所需的结果。这些解释也有助于核心动画和核心动画编程指南本身的转换矩阵的解释。

_graphic.transform = CGAffineTransformMakeRotation(-2.89724656);

CATransform3D rotatedTransform = _graphic.layer.transform;

rotatedTransform.m34 = 1.0 / 500;
rotatedTransform.m22 = -2;
rotatedTransform.m41 = 170;
rotatedTransform.m42 = 170;

rotatedTransform = 
CATransform3DRotate(rotatedTransform, 
                    51 * M_PI / 180.0f, 
                    1.0f, 
                    0.0f, 
                    0.0f);


_graphic.layer.transform = rotatedTransform;

[_graphic setNeedsDisplay];

Thank you all.

谢谢你们。

#1


1  

Given the information you have, sounds like you can use line-plane intersection to solve your problem.

根据您拥有的信息,听起来您可以使用线平面交叉点来解决您的问题。

#2


0  

I achieved the desired result by plotting the coordinate on a UIView and transform it using CATrasnform3D. These explanations also help, Explanation of Transformation Matrix in terms of Core Animation and Core Animation Programming Guide itself.

我通过在UIView上绘制坐标并使用CATrasnform3D对其进行转换来实现所需的结果。这些解释也有助于核心动画和核心动画编程指南本身的转换矩阵的解释。

_graphic.transform = CGAffineTransformMakeRotation(-2.89724656);

CATransform3D rotatedTransform = _graphic.layer.transform;

rotatedTransform.m34 = 1.0 / 500;
rotatedTransform.m22 = -2;
rotatedTransform.m41 = 170;
rotatedTransform.m42 = 170;

rotatedTransform = 
CATransform3DRotate(rotatedTransform, 
                    51 * M_PI / 180.0f, 
                    1.0f, 
                    0.0f, 
                    0.0f);


_graphic.layer.transform = rotatedTransform;

[_graphic setNeedsDisplay];

Thank you all.

谢谢你们。