首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在给定两个点的情况下创建MKMapRect,每个点指定一个纬度和经度值?

如何在给定两个点的情况下创建MKMapRect,每个点指定一个纬度和经度值?
EN

Stack Overflow用户
提问于 2014-06-04 04:13:54
回答 3查看 9.1K关注 0票数 32

我有一个自定义类,它扩展了NSObject并实现了MKOverlay协议。因此,我需要实现协议的boundingMapRect属性,它是一个MKMapRect。当然,我可以使用MKMapRectMake来创建一个MKMapRect。但是,我不知道如何使用我拥有数据创建MKMapRect,这些数据是两个点,每个点由一个纬度和一个经度指定。MKMapRectMake的文档状态:

代码语言:javascript
复制
MKMapRect MKMapRectMake(
    double x,
    double y,
    double width,
    double height
);

Parameters
x
    The point along the east-west axis of the map projection to use for the origin.
y
    The point along the north-south axis of the map projection to use for the origin.
width
    The width of the rectangle (measured using map points).
height
    The height of the rectangle (measured using map points).
Return Value
    A map rectangle with the specified values.

我必须指定MKMapRect的纬度和经度值是:

代码语言:javascript
复制
24.7433195, -124.7844079
49.3457868, -66.9513812

因此,目标MKMapRect需要指定一个如下所示的区域:

因此,重申一下,如何使用经度/纬度值创建一个可以设置为MKOverlay协议@property (nonatomic, readonly) MKMapRect boundingMapRect属性的MKMapRect

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24024135

复制
相关文章

相似问题

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