Flutter中的Google Map Navigation [英] Google Map Navigation in Flutter

查看:725
本文介绍了Flutter中的Google Map Navigation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的人.

我发现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?

推荐答案

您可以在flutter中使用android_intent库来启动googlemaps,并在android中获得成功.

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

并且在ios中,您可以同时使用comapimaps之类的google api或google map url {我选择此一个}和maps.apple.com.

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';
       }
    }

我希望能帮上忙.

这篇关于Flutter中的Google Map Navigation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆