Created
May 10, 2024 16:24
-
-
Save voncannon/f8ade0337360ebc701f487e7b2477f92 to your computer and use it in GitHub Desktop.
MapLibre SwiftUI Coordinator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// MapLibreCoordinator.swift | |
// Topo Lock Maps | |
// | |
// Created by VonCannon Technology, Inc. on 9/19/23. | |
// | |
import Foundation | |
import SwiftUI | |
import Mapbox | |
class MapLibreCoordinator: NSObject, MGLMapViewDelegate, UIGestureRecognizerDelegate { | |
weak var mapView: MGLMapView? | |
var mapStore: MapStore | |
init(mapStore: MapStore) { | |
self.mapStore = mapStore | |
super.init() | |
self.mapStore.mapCoordinater = self | |
} | |
func mapViewWillStartLoadingMap(_ mapView: MGLMapView) { | |
TLLog.log(type: .Map, statement: "mapViewWillStartLoadingMap") | |
if self.mapView != mapView { | |
self.mapView = mapView | |
} | |
} | |
func mapViewDidFailLoadingMap(_ mapView: MGLMapView, withError error: Error) { | |
TLLog.log(type: .Map, statement: "mapViewDidFailLoadingMap, error: \(error)") | |
if self.mapView != mapView { | |
self.mapView = mapView | |
} | |
} | |
func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) { | |
TLLog.log(type: .Map, statement: "mapView, didFinishLoading Style") | |
if self.mapView != mapView { | |
self.mapView = mapView | |
} | |
} | |
func mapViewDidFinishLoadingMap(_ mapView: MGLMapView) { | |
TLLog.log(type: .Map, statement: "mapViewDidFinishLoadingMap") | |
if self.mapView != mapView { | |
self.mapView = mapView | |
} | |
} | |
//MARK: Deinit | |
deinit { | |
mapStore.mapCoordinater = nil | |
TLLog.log(type: .App, statement: "***** MapLibreCoordinator DEINIT WAS CALLED ***** WE ARE GOOOD GOOOD GOOOD *****") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment