Skip to content

Instantly share code, notes, and snippets.

@johnnewman
johnnewman / ViewController.swift
Last active November 21, 2022 15:15
A controller that programmatically selects an annotation every 2 seconds
//
// ViewController.swift
//
// Created by John Newman on 11/18/22.
//
import UIKit
import MapboxMaps
class ViewController: UIViewController {
@johnnewman
johnnewman / ViewController.swift
Created September 8, 2022 22:07
Automatically refreshing view-based annotation coordinates
import UIKit
import MapboxMaps
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let mapView = MapView(frame: view.bounds)
mapView.autoresizingMask = [.flexibleHeight, .flexibleWidth]
@johnnewman
johnnewman / CircleManualUpdatePulse.swift
Last active March 10, 2022 22:32
CircleLayer rapid property update pulse
//
// CircleManualUpdatePulse.swift
//
// Created by John Newman on 3/10/22.
// Copyright © 2022 Roadtrippers LLC. All rights reserved.
//
import Foundation
import MapboxMaps
@johnnewman
johnnewman / CircleTransitionPulse.swift
Last active March 10, 2022 22:31
CircleLayer transition property pulse
//
// CircleTransitionPulse.swift
//
// Created by John Newman on 3/10/22.
// Copyright © 2022 Roadtrippers LLC. All rights reserved.
//
import Foundation
import MapboxMaps
import UIKit
@johnnewman
johnnewman / MapCenteringExample.swift
Last active January 7, 2022 16:46
This gist shows how the MapView's camera centering doesn't work properly until an indeterminate time after the map is presented
//
// ViewController.swift
// MapboxSample
//
// Created by John Newman on 2/07/22.
//
// Mapbox SDK v10.2.0-rc.1 and 10.2.0
//
// The map will successfully frame the camera:
// - always after the DispatchQueue.main.asyncAfter(deadline: .now() + 3) executes
@johnnewman
johnnewman / ChildNavigationViewControllerBug.swift
Last active July 28, 2021 20:49
Code to reproduce a Mapbox Navigation bug where polylines disappear from the map when transitioning to night
import MapboxDirections
import MapboxCoreNavigation
import MapboxNavigation
class ViewController: UIViewController {
var mbNavigationController: NavigationViewController!
let addNavigationViewControllerAsChild = true
@johnnewman
johnnewman / ViewController.swift
Created December 11, 2020 16:17
Navigation view controller example
//
// ViewController.swift
// EmptyMBNavProject
//
// Created by John Newman on 12/10/20.
//
import MapboxDirections
import MapboxCoreNavigation
import MapboxNavigation
@johnnewman
johnnewman / IconSortViewController.swift
Last active January 13, 2020 21:18
Code exhibiting a sorting issue with MGLSymbolStyleLayer
//
// IconSortViewController.swift
// IconOrdering
//
// Created by John Newman on 11/18/19.
// Copyright © 2019 Roadtrippers. All rights reserved.
//
import UIKit
import Mapbox