map_launcher 0.4.3

  • Readme
  • Changelog
  • Example
  • Installing
  • 97

Map Launcher #

pub package

Map Launcher is a flutter plugin to find available maps installed on a device and launch them with a marker for specified location.

AndroidiOS
ANDROIDiOS

Currently supported maps:
Google Maps
Apple Maps (iOS only)
Baidu Maps
Amap (Gaode Maps)
Waze
Yandex Maps
Yandex Navigator

Get started #

Add dependency #

dependencies:
  map_launcher: ^0.4.3

For iOS add url schemes in Info.plist file #

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>comgooglemaps</string>
    <string>baidumap</string>
    <string>iosamap</string>
    <string>waze</string>
    <string>yandexmaps</string>
    <string>yandexnavi</string>
</array>

Usage #

Get list of installed maps and launch first #

import 'package:map_launcher/map_launcher.dart';

final availableMaps = await MapLauncher.installedMaps;
print(availableMaps); // [AvailableMap { mapName: Google Maps, mapType: google }, ...]

await availableMaps.first.showMarker(
  coords: Coords(31.233568, 121.505504),
  title: "Shanghai Tower",
  description: "Asia's tallest building",
);

Check if map is installed and launch it #

import 'package:map_launcher/map_launcher.dart';

if (await MapLauncher.isMapAvailable(MapType.google)) {
  await MapLauncher.launchMap(
    mapType: MapType.google,
    coords: coords,
    title: title,
    description: description,
  );
}

Example using bottom sheet #

import 'package:flutter/material.dart';
import 'package:map_launcher/map_launcher.dart';

void main() => runApp(MapLauncherDemo());

class MapLauncherDemo extends StatelessWidget {
  openMapsSheet(context) async {
    try {
      final title = "Shanghai Tower";
      final description = "Asia's tallest building";
      final coords = Coords(31.233568, 121.505504);
      final availableMaps = await MapLauncher.installedMaps;

      showModalBottomSheet(
        context: context,
        builder: (BuildContext context) {
          return SafeArea(
            child: SingleChildScrollView(
              child: Container(
                child: Wrap(
                  children: <Widget>[
                    for (var map in availableMaps)
                      ListTile(
                        onTap: () => map.showMarker(
                          coords: coords,
                          title: title,
                          description: description,
                        ),
                        title: Text(map.mapName),
                        leading: Image(
                          image: map.icon,
                          height: 30.0,
                          width: 30.0,
                        ),
                      ),
                  ],
                ),
              ),
            ),
          );
        },
      );
    } catch (e) {
      print(e);
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Map Launcher Demo'),
        ),
        body: Center(child: Builder(
          builder: (context) {
            return MaterialButton(
              onPressed: () => openMapsSheet(context),
              child: Text('Show Maps'),
            );
          },
        )),
      ),
    );
  }
}

Known issues #

  • Google Maps for Android have a bug that setting label for a marker doesn't work. See more on Google Issue Tracker

Contributing #

Pull requests are welcome.

0.4.3 #

  • Add license

0.4.2 #

  • Add code to show title in Google Maps for Android. Should work once fixed in Google Maps. Update README.

0.4.1 #

  • Update README file. Remove author field from pubspec.yaml

0.4.0 #

  • Added support for Yandex Maps and Yandex Navigator
    Updated icons

0.3.2 #

  • Fixes #1 'MKCoordinateRegionMake' is unavailable in Swift
    Thanks to @diegogarciar

0.3.1 #

  • Throw a PlatformException if map is not installed

0.3.0 #

  • Added Waze support

0.2.0 #

  • Added method to check if map is available

0.1.3 #

  • Added icons for maps
  • Added iOS gif to README

0.1.2 #

  • Migrate to AndroidX

0.1.1 #

  • Update description in pubspec.yaml

0.1.0 #

  • Get available maps on iOS and Android
  • Launch maps with a marker

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:map_launcher/map_launcher.dart';

void main() => runApp(MapLauncherDemo());

class MapLauncherDemo extends StatelessWidget {
  openMapsSheet(context) async {
    try {
      final title = "Shanghai Tower";
      final description = "Asia's tallest building";
      final coords = Coords(31.233568, 121.505504);
      final availableMaps = await MapLauncher.installedMaps;

      print(availableMaps);

      showModalBottomSheet(
        context: context,
        builder: (BuildContext context) {
          return SafeArea(
            child: SingleChildScrollView(
              child: Container(
                child: Wrap(
                  children: <Widget>[
                    for (var map in availableMaps)
                      ListTile(
                        onTap: () => map.showMarker(
                          coords: coords,
                          title: title,
                          description: description,
                        ),
                        title: Text(map.mapName),
                        leading: Image(
                          image: map.icon,
                          height: 30.0,
                          width: 30.0,
                        ),
                      ),
                  ],
                ),
              ),
            ),
          );
        },
      );
    } catch (e) {
      print(e);
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Map Launcher Demo'),
        ),
        body: Center(child: Builder(
          builder: (context) {
            return MaterialButton(
              onPressed: () => openMapsSheet(context),
              child: Text('Show Maps'),
            );
          },
        )),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  map_launcher: ^0.4.3

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:map_launcher/map_launcher.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
94
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
97
Learn more about scoring.

We analyzed this package on Jul 5, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.13
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because of import path [package:map_launcher/map_launcher.dart] that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because of import path [package:map_launcher/map_launcher.dart] that declares support for platforms: android, ios

Package does not support Flutter platform web

Because of import path [package:map_launcher/map_launcher.dart] that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because of import path [package:map_launcher/map_launcher.dart] that declares support for platforms: android, ios

Package not compatible with SDK dart

because of import path [map_launcher] that is in a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8
Dev dependencies
flutter_test