0

[Google Maps app](https://i.stack.imgur.com/dAMmv.png)

so here's a picture from google map that I want to show the gas stations on my app like this because I want to make app that show the gas stations locations will anyone help me?

I need a code or hint about how to do it.

Karan Mehta
  • 1,442
  • 13
  • 32
AXP
  • 3
  • 3
  • 1
    Google is your guide https://codelabs.developers.google.com/codelabs/google-maps-in-flutter#4 – mares Apr 13 '23 at 00:23

1 Answers1

0

UPDATE:

For showing the Gas Stations only you need to apply a combination of custom Map Styling and POI filtering. These can be enabled from Google Cloud Project.

enter image description here

How to set the POI filtering

POI Filtering

NOTE The above process requires implementation of dynamic styling and Dynamic Maps SKU, which has its own billing system. Please refer to the Google Map Billing for more details.

To start with, try implementing static map styling to get an idea.

Implementing static map styling in Flutter using google_maps_flutter

 onMapCreated: (GoogleMapController controller) async {
        _controller = controller;
       _controller.setMapStyle(mapStyle);

Custom Style


    String mapStyle = '''
                        [
                          {
                            "elementType": "geometry",
                            "stylers": [
                              {
                                "color": "#242f3e"
                              }
                            ]
                          },
                          {
                            "elementType": "labels.text.fill",
                            "stylers": [
                              {
                                "color": "#746855"
                              }
                            ]
                          },
                          {
                            "elementType": "labels.text.stroke",
                            "stylers": [
                              {
                                "color": "#242f3e"
                              }
                            ]
                          },
                          {
                            "featureType": "administrative.locality",
                            "elementType": "labels.text.fill",
                            "stylers": [
                              {
                                "color": "#d59563"
                              }
                            ]
                          },
                          {
                            "featureType": "poi",
                            "elementType": "labels.text.fill",
                            "stylers": [
                              {
                                "color": "#d59563"
                              }
                            ]
                          },
                          {
                            "featureType": "poi.park",
                            "elementType": "geometry",
                            "stylers": [
                              {
                                "color": "#263c3f"
                              }
                            ]
                          },
                          {
                            "featureType": "poi.park",
                            "elementType": "labels.text.fill",
                            "stylers": [
                              {
                                "color": "#6b9a76"
                              }
                            ]
                          },
                          {
                            "featureType": "road",
                            "elementType": "geometry",
                            "stylers": [
                              {
                                "color": "#38414e"
                              }
                            ]
                          },
                          {
                            "featureType": "road",
                            "elementType": "geometry.stroke",
                            "stylers": [
                              {
                                "color": "#212a37"
                              }
                            ]
                          },
                          {
                            "featureType": "road",
                            "elementType": "labels.text.fill",
                            "stylers": [
                              {
                                "color": "#9ca5b3"
                              }
                            ]
                          },
                          {
                            "featureType": "road.highway",
                            "elementType": "geometry",
                            "stylers": [
                              {
                                "color": "#746855"
                              }
                            ]
                          },
                          {
                            "featureType": "road.highway",
                            "elementType": "geometry.stroke",
                            "stylers": [
                              {
                                "color": "#1f2835"
                              }
                            ]
                          },
                          {
                            "featureType": "road.highway",
                            "elementType": "labels.text.fill",
                            "stylers": [
                              {
                                "color": "#f3d19c"
                              }
                            ]
                          },
                          {
                            "featureType": "transit",
                            "elementType": "geometry",
                            "stylers": [
                              {
                                "color": "#2f3948"
                              }
                            ]
                          },
                          {
                            "featureType": "transit.station",
                            "elementType": "labels.text.fill",
                            "stylers": [
                              {
                                "color": "#d59563"
                              }
                            ]
                          },
                          {
                            "featureType": "water",
                            "elementType": "geometry",
                            "stylers": [
                              {
                                "color": "#17263c"
                              }
                            ]
                          },
                          {
                            "featureType": "water",
                            "elementType": "labels.text.fill",
                            "stylers": [
                              {
                                "color": "#515c6d"
                              }
                            ]
                          },
                          {
                            "featureType": "water",
                            "elementType": "labels.text.stroke",
                            "stylers": [
                              {
                                "color": "#17263c"
                              }
                            ]
                          }
                        ]
                    ''';

** END OF UPDATE **

You could try using Places API by enabling it inside API library in your Google Cloud project.

Google Places API

The functions in the Places Library, Maps JavaScript API enable your application to search for places (defined in this API as establishments, geographic locations, or prominent points of interest) contained within a defined area, such as the bounds of a map, or around a fixed point.

The Places API offers an autocomplete feature which you can use to give your applications the type-ahead-search behaviour of the Google Maps search field. When a user starts typing an address, autocomplete will fill in the rest.

This will enable you to find the nearest places of interest e.g gas stations, restaurants, hotels etc and get the location in the response data.

Once you get the latitude/Longitude from the response, parse accordingly and draw a marker on those places over Google Map. You could also add custom tooltip to those added markers to enhance users experience.

  • I did add the Place API but I can add a marker for these gas stations manually and this method will take ages until I mark every station! I want to know how to add them automatically by making the application filtering the map and show gas stations only like when I search on google map for gas stations, it will show only gas stations – AXP Apr 13 '23 at 06:52
  • @AXP I have updated my answer with additional infos. Have a look. Hope this helps – Niladri Raychaudhuri Apr 13 '23 at 09:46