You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Simple polylines & polygons don't appear if initialized with map #2322
Polylines and polygons that don't require much processing before being added to the map fail to ever appear, if initialized concurrently with the map. Adding the slightest delay or drawing the shapes in viewDidAppear causes them to appear as expected.
The GeoJSON example works when drawn directly in viewDidLoad. #2289 fixed this problem for markers and complex shapes, but I clearly must have missed the simple case during testing.
importMapboxclassViewController:UIViewController,MGLMapViewDelegate{varmapView:MGLMapView!
overridefuncviewDidLoad(){super.viewDidLoad()mapView=MGLMapView(frame:view.bounds)mapView.autoresizingMask=.FlexibleWidth|.FlexibleHeightmapView.setCenterCoordinate(CLLocationCoordinate2D(latitude:45.520486,longitude:-122.673541),zoomLevel:11,animated:false)view.addSubview(mapView)mapView.delegate=self
// this works
dispatch_after(dispatch_time(DISPATCH_TIME_NOW,0),dispatch_get_main_queue(),{self.drawShape()})
// this does not work
drawShape()}overridefuncviewDidAppear(animated:Bool){
// this works
drawShape()}funcdrawShape(){
// Create a coordinates array to hold all of the coordinates for our shape.
varcoordinates=[CLLocationCoordinate2D(latitude:45.522585,longitude:-122.685699),CLLocationCoordinate2D(latitude:45.534611,longitude:-122.708873),CLLocationCoordinate2D(latitude:45.530883,longitude:-122.678833),CLLocationCoordinate2D(latitude:45.547115,longitude:-122.667503),CLLocationCoordinate2D(latitude:45.530643,longitude:-122.660121),CLLocationCoordinate2D(latitude:45.533529,longitude:-122.636260),CLLocationCoordinate2D(latitude:45.521743,longitude:-122.659091),CLLocationCoordinate2D(latitude:45.510677,longitude:-122.648792),CLLocationCoordinate2D(latitude:45.515008,longitude:-122.664070),CLLocationCoordinate2D(latitude:45.502496,longitude:-122.669048),CLLocationCoordinate2D(latitude:45.515369,longitude:-122.678489),CLLocationCoordinate2D(latitude:45.506346,longitude:-122.702007),CLLocationCoordinate2D(latitude:45.522585,longitude:-122.685699),]letshape=MGLPolygon(coordinates:&coordinates,count:UInt(coordinates.count))mapView.addAnnotation(shape)}}
Activity
incanus commentedon Sep 14, 2015
Hmm, this shouldn't be related to #1675 / #2289 as shapes aren't dependent upon the sprite or sprite store initialization the way marker images are.
friedbunny commentedon Sep 14, 2015
Totally. Something definitely improved the timing issue that did exist, in any case, as
dispatch_afterzero seconds didn't previously work.Rewrite annotation invalidation strategy