It's well documented on the Google Maps web version, but I can't find the same feature in the Flutter GM module. I need to hide the points of interests from the map (shops, bus stops...) Is there any official / unofficial way to do it, or another module that would handle it ?
Click the "My Places" button just beneath the search bar. Click "Maps" and wait for the list of maps to appear down the left side of the screen. When they do, click the title of the map containing the marker that you want to remove.
You need to find that specific marker in your _markers list (e.g. by firstWhere()) and then remove it from the list of markers. Edit: Marker marker = _markers.
If anyone want to remove zoom control. Add zoomControlsEnabled: false to google map view.
You can use the setMapStyle
method on your GoogleMapController
:
yourMapController.setMapStyle('[{"featureType": "poi","stylers": [{"visibility": "off"}]}]');
To generate such strings for customizing the map style, you can use this website.
you can!
okay first as you know, GoogleMaps accepts theming, you can get dark or any customized map you like through this link (https://mapstyle.withgoogle.com) you can get json to insert in your app.
you can also follow this guide (https://medium.com/@matthiasschuyten/google-maps-styling-in-flutter-5c4101806e83).
okay to get back to your question, while theming you can turn on/off features and from those POI.
so you can add this to your json and POI will disappear
{
"featureType": "poi",
"stylers": [
{ "visibility": "off" }
]
}
if you want only default googleMaps with only POI removed you can use this json
[
{
"featureType": "poi",
"stylers": [
{ "visibility": "off" }
]
}
]
another example: this is my full settings. theming and at the end i disabled POI
[
{
"elementType": "geometry",
"stylers": [
{
"color": "#ebe3cd"
}
]
},
{
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#523735"
}
]
},
{
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#f5f1e6"
}
]
},
{
"featureType": "administrative",
"elementType": "geometry.stroke",
"stylers": [
{
"color": "#c9b2a6"
}
]
},
{
"featureType": "administrative.land_parcel",
"elementType": "geometry.stroke",
"stylers": [
{
"color": "#dcd2be"
}
]
},
{
"featureType": "administrative.land_parcel",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#ae9e90"
}
]
},
{
"featureType": "landscape.natural",
"elementType": "geometry",
"stylers": [
{
"color": "#dfd2ae"
}
]
},
{
"featureType": "poi",
"elementType": "geometry",
"stylers": [
{
"color": "#dfd2ae"
}
]
},
{
"featureType": "poi",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#93817c"
}
]
},
{
"featureType": "poi.park",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#a5b076"
}
]
},
{
"featureType": "poi.park",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#447530"
}
]
},
{
"featureType": "road",
"elementType": "geometry",
"stylers": [
{
"color": "#f5f1e6"
}
]
},
{
"featureType": "road.arterial",
"elementType": "geometry",
"stylers": [
{
"color": "#fdfcf8"
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [
{
"color": "#f8c967"
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry.stroke",
"stylers": [
{
"color": "#e9bc62"
}
]
},
{
"featureType": "road.highway.controlled_access",
"elementType": "geometry",
"stylers": [
{
"color": "#e98d58"
}
]
},
{
"featureType": "road.highway.controlled_access",
"elementType": "geometry.stroke",
"stylers": [
{
"color": "#db8555"
}
]
},
{
"featureType": "road.local",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#806b63"
}
]
},
{
"featureType": "transit.line",
"elementType": "geometry",
"stylers": [
{
"color": "#dfd2ae"
}
]
},
{
"featureType": "transit.line",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#8f7d77"
}
]
},
{
"featureType": "transit.line",
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#ebe3cd"
}
]
},
{
"featureType": "transit.station",
"elementType": "geometry",
"stylers": [
{
"color": "#dfd2ae"
}
]
},
{
"featureType": "water",
"elementType": "geometry.fill",
"stylers": [
{
"color": "#b9d3c2"
}
]
},
{
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#92998d"
}
]
},
{
"featureType": "poi",
"stylers": [
{
"visibility": "off"
}
]
}
]
Thor Mitchell, (Former Product Mgr, Google Maps API) said that here : (https://www.quora.com/How-do-I-remove-POI-from-the-Google-Maps-API)
that's all ^^
Edit (14 Oct 19) : so to be more clear. here is the steps, all of it.
1- create mapStyle.txt in assets folder ex:
and it contains just this text
[{
"featureType": "poi",
"stylers": [
{
"visibility": "off"
}
]
}]
2- add it to pubspec.yaml assets ex:
assets:
- assets/map_style.txt
3- in your map screen do the following
class MapScreen extends StatefulWidget {
@override
_MapScreenState createState() => _MapScreenState();
}
class _MapScreenState extends State<MapScreen> {
String _mapStyle;
GoogleMapController _mapController;
initState() {
super.initState();
rootBundle.loadString('assets/map_style.txt').then((string) {
_mapStyle = string;
});
}
//...
_onMapCreated(GoogleMapController controller) {
if (mounted)
setState(() {
_mapController = controller;
controller.setMapStyle(_mapStyle);
});
}
//...
@override
Widget build(BuildContext context) {
return GoogleMap(
initialCameraPosition: CameraPosition(
zoom: 15,
target: LatLng(
_currentPosition?.latitude,
_currentPosition?.longitude,
),
),
onMapCreated: _onMapCreated,
polylines: Set<Polyline>.of(_polyLines.values),
myLocationEnabled: true,
myLocationButtonEnabled: false,
mapType: MapType.normal,
compassEnabled: true,
);
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With