刚开始使用Mapbox,设法通过在locationManaged didUpdateLocations中添加它来绘制MGLPolyline
var shape = MGLPolyline(coordinates: &a, count: UInt(a.count))
mapView.addAnnotation(shape)
func mapView(mapView: MGLMapView, lineWidthForPolylineAnnotation annotation: MGLPolyline) -> CGFloat { return 20.0 }
答案 0 :(得分:4)
您需要将地图委托设置为self才能使功能正常工作。这是代码:
使用Advertisement.Show ("rewardedVideoZone");
currency += 10;
MGLMapViewDelegate
然后在设置地图后,像这样添加class yourController: UIViewController, CLLocationManagerDelegate, MKMapViewDelegate, MGLMapViewDelegate{
self.mapView.delegate = self
然后你的功能将起作用:
mapView = MGLMapView(frame: mapViewWrapper.bounds, styleURL: NSURL(string: Mapbox.getTheme()))
mapView = Mapbox.configure(mapView)
mapView.setCenterCoordinate(appleMap.userLocation.coordinate, zoomLevel: 12, animated: true)
mapViewWrapper.addSubview(mapView)
self.mapView.delegate = self
答案 1 :(得分:1)
@denislexic说了什么,但是请注意,一旦设置了初始宽度,就无法改变宽度。