首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >LatLonBox到CLLocationCoordinate2D

LatLonBox到CLLocationCoordinate2D
EN

Stack Overflow用户
提问于 2014-02-03 01:28:58
回答 1查看 182关注 0票数 0

我尝试将LatLonBox坐标转换为CLLocationCoordinate2D。但我认为在某个地方是个错误,因为死亡形象不适合..。

代码语言:javascript
运行
复制
 <LatLonBox>
  <north>2.254403</north>
  <south>-55.256903</south>
  <east>161.994477</east>
  <west>98.003023</west>
  <rotation>0</rotation>
</LatLonBox>

这里我的函数转换LatLonBox坐标。

** - MapOverlay : NSObject -*

代码语言:javascript
运行
复制
-(id)initWithNorth:(double)north south:(double)south west:(double)west east:(double)east imageStr:(NSString*)imageStr{

    self = [super init];
    if (self) {
        imageString = imageStr;

        CLLocationCoordinate2D lowerLeftCoordinate = CLLocationCoordinate2DMake(south, west); // south, west
        CLLocationCoordinate2D upperRightCoordinate = CLLocationCoordinate2DMake(north, east); //north,east


        baseCoordinate = lowerLeftCoordinate;

        MKMapPoint lowerLeft = MKMapPointForCoordinate(lowerLeftCoordinate);
        MKMapPoint upperRight = MKMapPointForCoordinate(upperRightCoordinate);

        mapRect = MKMapRectMake(lowerLeft.x, upperRight.y, upperRight.x - lowerLeft.x, lowerLeft.y - upperRight.y);
    }

    return self;
}

** - MapOverlayView : MKOverlayView -*

代码语言:javascript
运行
复制
- (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)ctx
{

    CGImageRef imageReference = image.CGImage;

    //Loading and setting the image
    MKMapRect theMapRect    =  [self.overlay boundingMapRect];
    CGRect theRect           = [self rectForMapRect:theMapRect];


    // We need to flip and reposition the image here
    CGContextScaleCTM(ctx, 1.0, -1.0);
    CGContextTranslateCTM(ctx, 0.0, -theRect.size.height);

    //drawing the image to the context
    CGContextDrawImage(ctx, theRect, imageReference);

}

**我的地图*

代码语言:javascript
运行
复制
//Adding the overlay to the map
MapOverlay * mapOverlay = [[MapOverlay alloc] initWithNorth:2.254403
                                                      south:-55.256903
                                                       west:161.994477
                                                       east:98.003023
                                                   imageStr:@"EarthquakeHazard.png"];
[self addOverlay:mapOverlay];

问题是,如果我改变了北方的价值。(-2.2544.)图像向下移动。那么它不应该上升到?

--好吧,这个功能工作得很好,而且很正确。我的.kml文件值错误.

谢谢你的帮助!

EN

回答 1

Stack Overflow用户

发布于 2014-02-03 04:00:44

代码语言:javascript
运行
复制
mapRect = MKMapRectMake(lowerLeft.x, upperRight.y, upperRight.x - lowerLeft.x, lowerLeft.y - upperRight.y);

很可能是

代码语言:javascript
运行
复制
mapRect = MKMapRectMake(lowerLeft.x, upperRight.y, upperRight.x - lowerLeft.x, upperRight.y - lowerLeft.y);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21518507

复制
相关文章

相似问题

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