给我路线:位置和路线屏幕位置

发布于 2024-11-29 21:47:36 字数 1016 浏览 5 评论 0原文

我正在地图视图上绘制一堆标记。 有关所有对象的位置信息(纬度和经度)都存储在数组中。 为了优化性能,我不想绘制所有标记。我只想在我目前看到的区域分配标记。但我从 Route Me API 获得的有关位置/屏幕的唯一信息是:

center.latitude;
center.longitude;

但此值仅返回整个地图的中心,我想查看实际视图的中心位置(纬度和经度)。我还能够获取 GPS 位置,但无法获取屏幕的中心位置。您认为有一种简单的方法可以获取这些信息吗?

这是我的实现的一部分:

UIImage* object = [UIImage imageNamed:@"object.png"];
CLLocationCoordinate2D buoyLocation;   
    NSString* templatString;
    NSString* templongString;

   for (int i =0; i<(myArray.count); i=i+2)

            {

            templongString = [myArray objectAtIndex:i];
            templatString = [myarray objectAtIndex:i+1];

            objectLocation.latitude  = [templatString floatValue];
            objectLocation.longitude  = [templongString floatValue];


            myMarker = [[RMMarker alloc] initWithUIImage:object anchorPoint:CGPointMake(xspec, yspec)]; //0.5 1.0            
            [markerManager1 addMarker:myMarker AtLatLong:objectLocation];


         }

I am drawing a bunch of Markers on my Map View.
The information about the position of all objects (latitude and longitude) is stored in an Array.
To optimize performance i don't want to draw ALL Markers. I only want to alloc Markers in the area i am seeing at the moment. But the only information i get from the Route Me API about position/screen is:

center.latitude;
center.longitude;

But this value is only returning the center of my whole map and i want to see the center position (lat and long) of the actual view. I am also able to get the GPS position, but not the center position of the screen. Do you think there is an easy way to get this information?

This is a part of my implementation:

UIImage* object = [UIImage imageNamed:@"object.png"];
CLLocationCoordinate2D buoyLocation;   
    NSString* templatString;
    NSString* templongString;

   for (int i =0; i<(myArray.count); i=i+2)

            {

            templongString = [myArray objectAtIndex:i];
            templatString = [myarray objectAtIndex:i+1];

            objectLocation.latitude  = [templatString floatValue];
            objectLocation.longitude  = [templongString floatValue];


            myMarker = [[RMMarker alloc] initWithUIImage:object anchorPoint:CGPointMake(xspec, yspec)]; //0.5 1.0            
            [markerManager1 addMarker:myMarker AtLatLong:objectLocation];


         }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

有木有妳兜一样 2024-12-06 21:47:36

查看 RMMapContents 中的 latitudeLongitudeBoundingBoxForScreen。

再见!

——兰迪

Take a look at latitudeLongitudeBoundingBoxForScreen in RMMapContents.

Ciao!

-- Randy

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文