Skip to content

Commit

Permalink
auto applied style on map created
Browse files Browse the repository at this point in the history
  • Loading branch information
itheamc committed Jun 7, 2024
1 parent 2bc6df6 commit 788a8a1
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions example/lib/local_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ class LocalStyleState extends State<LocalStyle> {

void _onMapCreated(MapLibreMapController controller) {
mapController = controller;

// Adding style to the map with some delay
Future.delayed(
const Duration(milliseconds: 250),
() async {
if (styleAbsoluteFilePath != null) {
await mapController?.setStyle(styleAbsoluteFilePath!);
}
},
);
}

@override
Expand All @@ -62,19 +72,12 @@ class LocalStyleState extends State<LocalStyle> {
}

return Scaffold(
floatingActionButton: FloatingActionButton.small(
child: const Icon(Icons.layers_outlined),
onPressed: () async {
if (styleAbsoluteFilePath != null) {
await mapController?.setStyle(styleAbsoluteFilePath!);
}
},
),
body: MapLibreMap(
onMapCreated: _onMapCreated,
initialCameraPosition: const CameraPosition(target: LatLng(0.0, 0.0)),
onStyleLoadedCallback: onStyleLoadedCallback,
));
body: MapLibreMap(
onMapCreated: _onMapCreated,
initialCameraPosition: const CameraPosition(target: LatLng(0.0, 0.0)),
onStyleLoadedCallback: onStyleLoadedCallback,
),
);
}

void onStyleLoadedCallback() {}
Expand Down

0 comments on commit 788a8a1

Please sign in to comment.