ios MKMapView 添加遮盖层

项目中涉及到运动轨迹,不希望别人看到自己的运动轨迹时可以隐藏地图的底图。

使用MKPolygon可以在MKMapView上添加遮盖层,尝试添加一个覆盖全世界的polygon失败,猜想可能是因为东经180度和西经180度在地球上是同一条线所以添加失败,因此使用两个polygon来覆盖全球。


funccreatePolygon1() ->MKPolygon{

// render whole map view for map hidden

letpoint1 =CLLocationCoordinate2D(latitude:-90, longitude:0)

letpoint2 =CLLocationCoordinate2D(latitude:-90, longitude:180)

letpoint3 =CLLocationCoordinate2D(latitude:90, longitude:180)

letpoint4 =CLLocationCoordinate2D(latitude:90, longitude:0)

letpoints = [point1, point2, point3, point4]

returnMKPolygon(coordinates: points, count: points.count)

}

funccreatePolygon2() ->MKPolygon{

// render whole map view for map hidden

letpoint1 =CLLocationCoordinate2D(latitude:-90, longitude:-180)

letpoint2 =CLLocationCoordinate2D(latitude:-90, longitude:0)

letpoint3 =CLLocationCoordinate2D(latitude:90, longitude:0)

letpoint4 =CLLocationCoordinate2D(latitude:90, longitude:-180)

letpoints = [point1, point2, point3, point4]

returnMKPolygon(coordinates: points, count: points.count)

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容