Add native location-provider override (setExternalLocation) - #1145
Open
trueshail wants to merge 1 commit into
Open
Add native location-provider override (setExternalLocation)#1145trueshail wants to merge 1 commit into
trueshail wants to merge 1 commit into
Conversation
trueshail
force-pushed
the
pr/external-location-provider
branch
2 times, most recently
from
September 4, 2026 00:12
7fd6db0 to
8735c9b
Compare
Adds a custom LocationProvider on both platforms so the map puck can be driven by an externally-supplied location instead of Mapbox's own GPS-only location engine: - iOS: ExternalLocationProvider.swift implements LocationProvider + HeadingProvider, registered via mapView.location.override(provider:). - Android: ExternalLocationProvider.kt implements LocationProvider, registered via mapView.location.setLocationProvider(...). - Both: a hand-written FlutterMethodChannel/MethodChannel exposing setExternalLocation/clearExternalLocation, deliberately NOT Pigeon-generated (Mapbox doesn't publish the Pigeon input specs for this plugin, only the generated output), kept isolated in LocationController/LocationComponentController to stay easy to rebase onto future upstream releases. - Dart: LocationSettings.setExternalLocation/.clearExternalLocation wrap the new channel. The override activates lazily on first setExternalLocation call and clearExternalLocation restores the platform default provider (GPS) - until called, map behavior is unchanged from stock mapbox_maps_flutter. Verified: flutter analyze clean, full test suite passing (29/29, including 3 new tests for the new channel), and real iOS simulator + Android debug builds of the example app both succeed. Branched from v2.29.0.
trueshail
force-pushed
the
pr/external-location-provider
branch
from
September 4, 2026 13:34
8735c9b to
89ff52b
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a way to drive the map puck from an externally-supplied location instead of Mapbox's own GPS-only location engine — a custom
LocationProvider/HeadingProvideron both platforms, wired through a smallsetExternalLocation/clearExternalLocationAPI onLocationSettings.Resolves #1085.
What's here
ExternalLocationProvider.swiftimplementsLocationProvider+HeadingProvider, registered viamapView.location.override(provider:).ExternalLocationProvider.ktimplementsLocationProvider, registered viamapView.location.setLocationProvider(...).FlutterMethodChannel/MethodChannelexposingsetExternalLocation/clearExternalLocation, kept isolated inLocationController/LocationComponentControllerso it stays easy to rebase onto future releases. This is deliberately not Pigeon-generated — the Pigeon input specs for this plugin aren't published, only the generated output.LocationSettings.setExternalLocation/.clearExternalLocationwrap the new channel.setExternalLocationitself, and a CHANGELOG entry.The override activates lazily on the first
setExternalLocationcall;clearExternalLocationrestores the platform default provider (GPS). Until either is called, map behavior is unchanged from stockmapbox_maps_flutter— this is purely additive.Usage
Motivation
Useful for apps that need to drive the puck from a custom positioning source — e.g. an indoor-positioning SDK while inside a mapped venue, falling back to GPS outdoors — without Mapbox's own location engine ever being in the loop. Per #1085, this seems like a capability others have asked for too.
Testing
flutter analyzeclean on the touched files.test/external_location_test.dart).Rebased onto current
mainfrom our original branch point at v2.29.0 — no conflicts.