import 'package:map_launcher/map_launcher.dart';

class AppMapLocation {
  static List<AvailableMap> availableMaps = [];
  static List availableMapsToNames = [];

  static Future<void> checkInstalledApps() async {
    availableMaps = await MapLauncher.installedMaps;
    availableMapsToNames = availableMaps.map((AvailableMap m) {
      String v = "";
      switch (m.mapType) {
        case MapType.baidu:
          v = '百度地图';
          break;
        case MapType.tencent:
          v = '腾讯地图';
          break;
        case MapType.amap:
          v = '高德地图';
          break;
        case MapType.apple:
          v = 'Apple地图';
          break;
        case MapType.google:
          v = 'Google地图';
          break;
        case MapType.googleGo:
          v = 'Google地图Go';
          break;
        case MapType.petal:
          v = 'Petal地图';
          break;
        default:
          v = m.mapName;
      }
      return v;
    }).toList();
  }

  static void launchMap(index, title, double latitude, double longitude) async {
    await availableMaps[index].showMarker(
      coords: Coords(latitude, longitude),
      title: title,
    );
  }
}
