-1

I'm using Google Maps in a Flutter app. I'm looking for a way to style the map on a black and white edition. I've seen this done in web editions, but not sure if it's possible in the Flutter edition...yet. Wonder if anyone else has achieved this and how?

4

1 Answer 1

7

First you have to get a style.json from: https://mapstyle.withgoogle.com/ and add it to your assets.

  assets:
    - assets/json_assets/

Then you add this to your init State where the google Maps widget is

  @override
  void initState() {
    super.initState();
    rootBundle.loadString('assets/json_assets/map_style.txt').then((string) {
      _mapStyle = string;
    });
  }

and last but not least your Map Created function should look like this:

  void _onMapCreated(GoogleMapController controller) {
    controller.setMapStyle(_mapStyle);
    _mapController = controller;
    initMemoryClustering();
  }
1
  • Thanks, I found the styling, but missed the setMapStyle. Thank you :) Dec 11, 2019 at 10:36

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.