在MKMapView IOS 7中绘制多边形是不正确的 [英] Drawing a polygon in MKMapView IOS 7 is not correct

查看:106
本文介绍了在MKMapView IOS 7中绘制多边形是不正确的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MKMapView 中,我使用以下几点创建了一个多边形:

In MKMapView, I created a polygon using these points:

1- lat = 0.0; long = -170;
2- lat = 0.0; long =  170;
3- lat = 10; long = 180;

前两个点相距仅20度,但是MKMapView将它拉向另一个方向。世界(相隔170 + 170 = 340度)。

The first two points are only 20 degrees apart, but the MKMapView draws it in the other direction around the world (which is 170 + 170 = 340 degrees apart).

有没有解决方法?

推荐答案

我很惊讶你在iOS 7中遇到这个问题,因为它们比以前的版本更好地处理经络。在iOS 7中,以下内容:

I'm surprised you're having issues with this in iOS 7, as they handle spanning the meridian better than prior versions. In iOS 7, the following:

CLLocationCoordinate2D coordinates[3];
coordinates[0] = CLLocationCoordinate2DMake(0, -170);
coordinates[1] = CLLocationCoordinate2DMake(0, 170);
coordinates[2] = CLLocationCoordinate2DMake(10, 180);
MKPolygon *polygon = [MKPolygon polygonWithCoordinates:coordinates count:3];
[self.mapView addOverlay:polygon];

产生(假设你实现了典型的 rendererForOverlay ):

produces (assuming you implement the typical rendererForOverlay):

在以前的iOS版本中执行此操作,可能无法正确处理此问题,但在iOS 7中,您应该没问题。如果您仍然遇到问题,也许您可​​以分享如何生成此多边形。

Doing this in prior iOS versions, it may not handle this properly, but in iOS 7, you should be fine. If you are still having issues, perhaps you can share how you've generated this polygon.

这篇关于在MKMapView IOS 7中绘制多边形是不正确的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆