Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Map Navigation in Flutter

I'm new to flutter.

I found Flutter doesn't support inline map, only a static map view.

I wanted to build an app which I need to show the driving directions on the map.

Is it possible to create the same in flutter?

enter image description here

like image 924
Jayadeep Avatar asked Jul 14 '18 11:07

Jayadeep


People also ask

How do you implement Google Maps Navigation in Flutter?

To use Google Maps in your Flutter app, you need to configure an API project with the Google Maps Platform, following the Maps SDK for Android's Using API key, Maps SDK for iOS' Using API key, and Maps JavaScript API's Using API key.

Is Google Maps free for Flutter?

Save this answer. Show activity on this post. google map api is free for android and ios platform. it will not charge you.


1 Answers

you can use android_intent library in flutter for starting googlemaps and get diection in android.

library : https://pub.dartlang.org/packages/android_intent

and in ios you can use both google api like comgooglemaps or google map url {i choose this one} and maps.apple.com.

String origin="somestartLocationStringAddress or lat,long";  // lat,long like 123.34,68.56
String destination="someEndLocationStringAddress or lat,long";
if (new LocalPlatform().isAndroid) {
      final AndroidIntent intent = new AndroidIntent(
          action: 'action_view',
          data: Uri.encodeFull(
              "https://www.google.com/maps/dir/?api=1&origin=" +
                  origin + "&destination=" + destination + "&travelmode=driving&dir_action=navigate"),
          package: 'com.google.android.apps.maps');
      intent.launch();
    }
    else {
        String url = "https://www.google.com/maps/dir/?api=1&origin=" + origin + "&destination=" + destination + "&travelmode=driving&dir_action=navigate";
        if (await canLaunch(url)) {
              await launch(url);
       } else {
            throw 'Could not launch $url';
       }
    }

i hope it helps.

like image 54
benyamin Avatar answered Sep 16 '22 14:09

benyamin