MapBox interiorPolygons 无法显示某些区域的孔
MapBox interiorPolygons can not show the hole in some area
平台:xcode9.2iOSobjective-c
Mapbox SDK 版本:Mapbox-iOS-SDK (3.7.2)
预期行为
我想在世界迷雾的某个区域挖一些洞,大部分区域都能出现。但有些区域不能显示孔。例如下面的代码:
一个六边形孔
Ulitsa Malaya Polyanka, 5, 莫斯科, 俄罗斯, 119180
纬度:55.735024 |经度:37.617188.
实际行为
该地区没有洞
Ulitsa Malaya Polyanka, 5, 莫斯科, 俄罗斯, 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];
我用一些技巧解决了这个问题。将地球分为南北两部分。每个部分都有切口阵列。代码如下
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];
平台:xcode9.2iOSobjective-c Mapbox SDK 版本:Mapbox-iOS-SDK (3.7.2)
预期行为 我想在世界迷雾的某个区域挖一些洞,大部分区域都能出现。但有些区域不能显示孔。例如下面的代码: 一个六边形孔 Ulitsa Malaya Polyanka, 5, 莫斯科, 俄罗斯, 119180 纬度:55.735024 |经度:37.617188.
实际行为 该地区没有洞 Ulitsa Malaya Polyanka, 5, 莫斯科, 俄罗斯, 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];
我用一些技巧解决了这个问题。将地球分为南北两部分。每个部分都有切口阵列。代码如下
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];