平台:xcode 9.2 iOS objective-c Mapbox SDK版本:Mapbox-iOS-SDK(3.7.2)
预期的行为 我想在世界雾的某些区域挖一些洞,大部分区域都可以出现。但有些地区无法显示漏洞。例如下面的代码: 六角形的一个洞 Ulitsa Malaya Polyanka,5,Moskva,Russia,119180 纬度:55.735024 |经度:37.617188。
实际行为 该地区没有洞 Ulitsa Malaya Polyanka,5,Moskva,Russia,119180 纬度:55.735024 |经度:37.617188。
CLLocationCoordinate2D lightCoordinate[6] = { {55.735024042991469, 37.617187500000007}, {55.742165827861974,37.595214843749993}, {55.75644547726997, 37.595214843749993}, {55.763583342064059, 37.617187500000007}, {55.75644547726997, 37.639160156249993}, {55.742165827861974, 37.639160156249993} };
NSUInteger numberOfLightCoordinates = sizeof(lightCoordinate) / sizeof(CLLocationCoordinate2D);
MGLPolygon *lightPolygon = [MGLPolygon polygonWithCoordinates:lightCoordinate count:numberOfLightCoordinates];
NSArray<MGLPolygon *> *lightPolygonArray = @[lightPolygon];
CLLocationCoordinate2D worldCoords[6] = { {90, 0}, {90, 180}, {-90,180}, {-90,0}, {-90,-180}, {90,-180} };
NSUInteger numberOfWorldCoords = sizeof(worldCoords) / sizeof(CLLocationCoordinate2D);
MGLPolygon *worldOverlay = [MGLPolygon polygonWithCoordinates:worldCoords
count:numberOfWorldCoords
interiorPolygons:lightPolygonArray];
//the array can have more than one "cutout" if needed
[self.mapBoxView addOverlay:self.worldOverlay];
答案 0 :(得分:0)
我用一些技巧解决了这个问题。将地球分为北部和南部。每个部分都有切口阵列。代码如下所示
CLLocationCoordinate2D northWorldCoords[4] = { {0, -180}, {0, 180}, {90, 180}, {90, -180}};
NSUInteger northNumberOfWorldCoords = sizeof(northWorldCoords) / sizeof(CLLocationCoordinate2D);
_northWorldOverlay = [MGLPolygon polygonWithCoordinates:northWorldCoords
count:northNumberOfWorldCoords
interiorPolygons:northLightPolygonArray];
//the array can have more than one "cutout" if needed
[self.chillViewController.mapBoxView addOverlay:_northWorldOverlay];
CLLocationCoordinate2D southWorldCoords[4] = {{0, -180}, {0, 180}, {-90, 180}, {-90, -180}};
NSUInteger southNumberOfWorldCoords = sizeof(southWorldCoords) / sizeof(CLLocationCoordinate2D);
_southWorldOverlay = [MGLPolygon polygonWithCoordinates:southWorldCoords
count:southNumberOfWorldCoords
interiorPolygons:southLightPolygonArray];
//the array can have more than one "cutout" if needed
[self.chillViewController.mapBoxView addOverlay:_southWorldOverlay];