给我路线:位置和路线屏幕位置
我正在地图视图上绘制一堆标记。 有关所有对象的位置信息(纬度和经度)都存储在数组中。 为了优化性能,我不想绘制所有标记。我只想在我目前看到的区域分配标记。但我从 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
查看 RMMapContents 中的 latitudeLongitudeBoundingBoxForScreen。
再见!
——兰迪
Take a look at latitudeLongitudeBoundingBoxForScreen in RMMapContents.
Ciao!
-- Randy