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?
-
1Possible duplicate of stackoverflow.com/questions/49953913/flutter-styled-map– MrUpsidownDec 11, 2019 at 9:48
-
Also I was able to find examples and documentation in like 10 seconds by searching the web...– MrUpsidownDec 11, 2019 at 9:49
-
Well then you found something that helped me and I missed– Rasmus ChristensenDec 11, 2019 at 10:35
-
The answer you accepted is basically a copy+paste of this article without the details...– MrUpsidownDec 11, 2019 at 10:39
Add a comment
|
1 Answer
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();
}
-
Thanks, I found the styling, but missed the setMapStyle. Thank you :) Dec 11, 2019 at 10:36