Skip to content

Commit

Permalink
Fix accessory location focus
Browse files Browse the repository at this point in the history
  • Loading branch information
wangwillian0 committed May 28, 2023
1 parent 9147242 commit 4e21755
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/map/map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ class _AccessoryMapState extends State<AccessoryMap> {
var accessories = accessoryRegistry.accessories;
if (!accessoryInitialized && accessoryRegistry.initialLoadFinished) {
fitToContent(accessories, locationModel.here);

accessoryInitialized = true;
}

Expand All @@ -86,8 +85,11 @@ class _AccessoryMapState extends State<AccessoryMap> {
}
}

onStyleLoaded() {
_mapController!.addCircles(
updateMarkers(MapboxMapController controller) {
controller.removeCircles(controller.circles);
controller.removeSymbols(controller.symbols);

controller.addCircles(
accessories
.where((accessory) => accessory.lastLocation != null)
.map((accessory) => CircleOptions(
Expand All @@ -99,7 +101,7 @@ class _AccessoryMapState extends State<AccessoryMap> {
))
.toList(),
);
_mapController!.addSymbols(
controller.addSymbols(
accessories
.where((accessory) => accessory.lastLocation != null)
.map((accessory) => SymbolOptions(
Expand All @@ -114,14 +116,17 @@ class _AccessoryMapState extends State<AccessoryMap> {
))
.toList(),
);

}

if (_mapController != null) {
updateMarkers(_mapController!);
}

return MapboxMap(
myLocationEnabled: true,
accessToken: const String.fromEnvironment("MAP_SDK_PUBLIC_KEY"),
onMapCreated: onMapCreated,
onStyleLoadedCallback: onStyleLoaded,
onStyleLoadedCallback: () => updateMarkers(_mapController!),
initialCameraPosition: CameraPosition(
target: locationModel.here ?? const LatLng(-23.559389, -46.731839),
zoom: 13.0,
Expand Down

0 comments on commit 4e21755

Please sign in to comment.