我希望在Mapbox中添加模糊效果。当第一次加载地图时,只显示当前位置,其他地图为蓝色。请参见截图。
当我将用户位置移动到另一个位置时,地图上的其他位置会变得清晰可见。还会在特定位置显示注释。请参见截图。我希望你能帮助我实现以下内容:
下面是一些实现代码:
- (CGPoint)convertLatLongCoord:(CGPoint)latLong {
CGSize screenSize = [UIScreen mainScreen].applicationFrame.size];
CGFloat SCALE = MIN(screenSize.width, screenSize.height) / (2.0 * EARTH_RADIUS);
CGFloat OFFSET = MIN(screenSize.width, screenSize.height) / 2.0;
CGFloat x = EARTH_RADIUS * cos(latLong.x) * cos(latLong.y) * SCALE + OFFSET;
CGFloat y = EARTH_RADIUS * cos(latLong.x) * sin(latLong.y) * SCALE + OFFSET;
return CGPointMake(x, y);
}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations
{
NSLog(@"data=%f",self.mapview.userLocation.coordinate.latitude);
CLLocation *currentLoc=[locations objectAtIndex:0];
_coordinate=currentLoc.coordinate;
CGPoint latLong = {_coordinate.latitude, _coordinate.longitude};
oldcord = [self convertLatLongCoord:latLong];
NSLog(@"Cartesian Coordinate: (%f, %f)",oldcord.x, oldcord.y);
}
在这段代码中,我将获取UserLocation坐标的完美视图像素点。然后,我想使用CGPoint清除视图中的模糊效果,但我无法获得它。我认为我将创建一个CGPoint数组,然后使用线条来清除视图的模糊效果,但我无法理解它,请给我建议。
我也尝试使用这个库,但我无法理解太多:https://github.com/DenHeadless/Shapes
MapBox
一无所知,你可以将 iOS 地图保持在视图隐藏状态下并进行正确的计算,GPS 位置仍会在 MapBox 地图上移动,这只是一个想法。你可以随时深入研究 MapBox 类、教程和论坛以寻找答案,你的解决方案的基本思路已经在示例中了,这就是做事的方式。 - iphonic