使用mapbox自定义MGLPolyline

时间:2015-08-15 11:57:21

标签: swift mapkit mapbox

刚开始使用Mapbox,设法通过在locationManaged didUpdateLocations中添加它来绘制MGLPolyline

   var shape = MGLPolyline(coordinates: &a, count: UInt(a.count))
   mapView.addAnnotation(shape) 
  1. 更改线宽并不会在屏幕上更改
  2. func mapView(mapView: MGLMapView, lineWidthForPolylineAnnotation annotation: MGLPolyline) -> CGFloat { return 20.0 }

    1. 如何将笔触默认颜色从黑色更改为其他颜色?

2 个答案:

答案 0 :(得分:4)

您需要将地图委托设置为self才能使功能正常工作。这是代码:

使用Advertisement.Show ("rewardedVideoZone"); currency += 10;

启动viewController
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说了什么,但是请注意,一旦设置了初始宽度,就无法改变宽度。