Conversation
trueshail
force-pushed
the
pr/external-location-provider
branch
3 times, most recently
from
September 4, 2026 13:34
8735c9b to
89ff52b
Compare
Adds a custom LocationProvider on both mobile platforms so the map puck can be driven by an externally-supplied location instead of the default GPS-only location engine. Useful when the location comes from an indoor-positioning SDK, a simulation, or a vehicle's own sensors. Resolves mapbox#1085. - platform_interface: LocationSettingsPlatformInterface gains setExternalLocation/clearExternalLocation. - mapbox_maps_flutter: LocationSettingsManager forwards both to the platform implementation. - mobile (Dart): LocationSettings backs them with a hand-written MethodChannel, deliberately NOT Pigeon-generated -- this repo ships the generated Pigeon output but not the input specs, so the channel is kept isolated from generated code and easy to regenerate around. - mobile (iOS): ExternalLocationProvider.swift implements LocationProvider + HeadingProvider, registered via mapView.location.override(provider:). - mobile (Android): ExternalLocationProvider.kt implements LocationProvider, registered via mapView.location.setLocationProvider. - web: throws UnsupportedError. GL JS's GeolocateControl owns the puck position and exposes no location-provider override. The override activates lazily on the first setExternalLocation call, so puck behaviour is unchanged until it is used; clearExternalLocation restores the platform default provider (GPS). floor is applied on iOS only, whose native Location type carries it; Android's LocationConsumer API has no floor concept, so it is dropped there. Verified: flutter analyze reports no new issues (247 before and after, all pre-existing), and all four package test suites pass (286 tests), including 3 new channel tests in mobile and 3 new delegation tests in the facade. Ported to the v3 federated package layout; the original version of this change targeted the pre-v3 flat layout on the 2.x line.
trueshail
force-pushed
the
pr/external-location-provider
branch
from
September 21, 2026 15:32
89ff52b to
9d4c230
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 the default GPS-only location engine — a custom
LocationProvider/HeadingProvideron both mobile platforms, wired through a smallsetExternalLocation/clearExternalLocationAPI on the location settings.Resolves #1085.
Updated for v3: this branch has been ported from the pre-v3 flat layout to the federated package structure introduced in #19427.
What's here
mapbox_maps_flutter_platform_interface:LocationSettingsPlatformInterfacegainssetExternalLocation/clearExternalLocation.mapbox_maps_flutter:LocationSettingsManagerforwards both to the platform implementation.mapbox_maps_flutter_mobile(Dart):LocationSettingsbacks them with a hand-writtenMethodChannel. This is deliberately not Pigeon-generated — the Pigeon input specs for this plugin aren't published, only the generated output — so the channel is kept isolated from generated code.mapbox_maps_flutter_mobile(iOS):ExternalLocationProvider.swiftimplementsLocationProvider+HeadingProvider, registered viamapView.location.override(provider:).mapbox_maps_flutter_mobile(Android):ExternalLocationProvider.ktimplementsLocationProvider, registered viamapView.location.setLocationProvider(...).mapbox_maps_flutter_web: throwsUnsupportedError. GL JS'sGeolocateControlowns the puck position and exposes no location-provider override, so there is nothing to override.The override activates lazily on the first
setExternalLocationcall;clearExternalLocationrestores the platform default provider (GPS). Until either is called, puck behavior is unchanged — this is purely additive.flooris applied on iOS only, whose nativeLocationtype carries it. Android'sLocationConsumerAPI has no floor concept, so it's dropped there; this is documented on the API.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 the platform's own location engine ever being in the loop. Per #1085, this is a capability others have asked for too.
Testing
flutter analyzeacross the workspace reports no new issues: 247 before and after this change, all pre-existing.mapbox_maps_flutter_mobile/test/external_location_test.dartand 3 new delegation tests inmapbox_maps_flutter/test/location_settings_test.dart.LocationComponentController.ktandLocationController.swiftare byte-identical between the 2.x and v3 trees, so the port moved them without modification. The example app has not been rebuilt against v3 as part of this port — worth a CI run before merge.Note on API shape
I've added the two methods directly to
LocationSettingsPlatformInterface, which makes them required for any implementer. If you'd prefer them optional (default implementations that throw, so out-of-tree platform implementations don't break), say the word and I'll restructure.