Swift 使用mapbox自定义MGLPolyline
刚开始使用Mapbox,通过将其添加到locationManaged didUpdateLocations中来绘制MGLPolylineSwift 使用mapbox自定义MGLPolyline,swift,mapkit,mapbox,Swift,Mapkit,Mapbox,刚开始使用Mapbox,通过将其添加到locationManaged didUpdateLocations中来绘制MGLPolyline var shape = MGLPolyline(coordinates: &a, count: UInt(a.count)) mapView.addAnnotation(shape) 更改线宽不会在屏幕上更改它 func mapViewmapView:MGLMapView,多段线的线宽注释:MGLPolyline->CGFloat{re
var shape = MGLPolyline(coordinates: &a, count: UInt(a.count))
mapView.addAnnotation(shape)
更改线宽不会在屏幕上更改它
func mapViewmapView:MGLMapView,多段线的线宽注释:MGLPolyline->CGFloat{return 20.0}
如何将笔划默认颜色从黑色更改为其他颜色?
您需要将映射委托设置为self才能使函数工作。代码如下: 使用MGLMapViewDelegate启动viewController 然后在设置映射后,添加self.mapView.delegate=self-like-so 然后,您的功能将正常工作:
func mapView(mapView: MGLMapView, alphaForShapeAnnotation annotation: MGLShape) -> CGFloat {
// Set the alpha for all shape annotations to 1 (full opacity)
return 1
}
func mapView(mapView: MGLMapView, lineWidthForPolylineAnnotation annotation: MGLPolyline) -> CGFloat {
// Set the line width for polyline annotations
return 5.0
}
func mapView(mapView: MGLMapView, strokeColorForShapeAnnotation annotation: MGLShape) -> UIColor {
// Give our polyline a unique color by checking for its `title` property
return UIColor.redColor()
}
您需要将映射委托设置为self才能使函数工作。代码如下: 使用MGLMapViewDelegate启动viewController 然后在设置映射后,添加self.mapView.delegate=self-like-so 然后,您的功能将正常工作:
func mapView(mapView: MGLMapView, alphaForShapeAnnotation annotation: MGLShape) -> CGFloat {
// Set the alpha for all shape annotations to 1 (full opacity)
return 1
}
func mapView(mapView: MGLMapView, lineWidthForPolylineAnnotation annotation: MGLPolyline) -> CGFloat {
// Set the line width for polyline annotations
return 5.0
}
func mapView(mapView: MGLMapView, strokeColorForShapeAnnotation annotation: MGLShape) -> UIColor {
// Give our polyline a unique color by checking for its `title` property
return UIColor.redColor()
}
@denislexic说了什么,但也要注意,一旦设置了初始宽度,就不能更改宽度 正如@denislexic所说,但也要注意,一旦设置了初始宽度,就不能更改宽度 有没有想过如何以3d格式显示多边形线条,比如MapBox在他们的博客视频中提到了什么?有没有想过如何以3d格式显示多边形线条,比如MapBox在他们的博客视频中提到了什么?
func mapView(mapView: MGLMapView, alphaForShapeAnnotation annotation: MGLShape) -> CGFloat {
// Set the alpha for all shape annotations to 1 (full opacity)
return 1
}
func mapView(mapView: MGLMapView, lineWidthForPolylineAnnotation annotation: MGLPolyline) -> CGFloat {
// Set the line width for polyline annotations
return 5.0
}
func mapView(mapView: MGLMapView, strokeColorForShapeAnnotation annotation: MGLShape) -> UIColor {
// Give our polyline a unique color by checking for its `title` property
return UIColor.redColor()
}