Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

map launcher

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

android ios
for launching maps ios

currently supported maps:

  • google maps
  • baidu maps
  • amap (gaode maps)
  • apple maps (ios only)

get started for launching maps

add dependency

dependencies:
  map_launcher: any

for ios add url schemes in info.plist file

<key>lsapplicationqueriesschemes</key>
<array>
    <string>comgooglemaps</string>
    <string>baidumap</string>
    <string>iosamap</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'),
            );
          },
        )),
      ),
    );
  }
}

Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.