Add Google map to Flutter with custom markers

Adding Google map to your Flutter project is not very big task. You can do this just by following a few simple steps.

First of all, add google_maps_flutter to your flutter project using the below command.

flutter pub add google_maps_flutter

OR add following to your pubspec.yaml file and do ‘flutter pub get’

dependencies:
google_maps_flutter:

Now create a dart file containing following code.

View this gist on GitHub

We’ve created a simple map. Now we’ll need to display markers in the desired locations.

Now add default markers.

View this gist on GitHub

Add markerLocations to GoogleMap().

View this gist on GitHub

We’ve added default markers to map. Now we just need to use markers with our own icons. First you need to add icon images to your assets folder. Now give path of your icons assets to marker such as Marker(icon: “assets/myicon.png”).

Now with Custom Icon markers :-

Leave a Reply