mattermoran / map_launcher

Flutter plugin for launching maps
MIT License
259 stars 117 forks source link

Google Maps not available on IOS even though it is installed. #177

Closed niesamowityrycerz closed 1 month ago

niesamowityrycerz commented 1 month ago

Hi Thanks for writing this package - I really like it! :) I am having problem with opening the Google Maps App on my Iphone 13 mini(iOS 17.4.1). In the logs I see this error:

StandardMethodCodec.decodeEnvelope
FlutterError - PlatformException(MAP_NOT_AVAILABLE, Map is not installed on a device, null, null)

This is is my code:

openMapSheet(String? venueLocationName, Coords originCoords, Coords destinationCoords, int eventId) async {
  final availableMaps = await MapLauncher.installedMaps;
  String availableMapsAsString = "";
  for(var map in availableMaps) {
    availableMapsAsString += map.mapName;
    availableMapsAsString += " ";
  }
  FirebaseAnalyticsService.logUserAvailableMaps(availableMapsAsString);

  return showModalBottomSheet(
      shape: const RoundedRectangleBorder(
      borderRadius: BorderRadius.only(
          topLeft: Radius.circular(20),
          topRight: Radius.circular(20)
        )
      ),
      backgroundColor: AppTextStyles.mainAppColor,
      context: context,
      builder: (context) {
        return SingleChildScrollView(
          child: Container(
            padding: const EdgeInsets.all(10.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Helpers.closeScheetButton(context, true),
                Helpers.sizedBoxHeightSeparator(),
                Text(
                  "Select app to navigate",
                  style: AppTextStyles.citySelectorMainTheme.labelMedium
                ),
                Helpers.sizedBoxHeightSeparator(),
                ListTile(
                  onTap: () {
                    FirebaseAnalyticsService.logUserUsesNavigation(eventId, "Apple Maps");
                    Navigator.of(context).pop();
                    MapLauncher.showDirections(
                      mapType: MapType.apple,
                      origin: originCoords,
                      originTitle: "Your location",
                      destination: destinationCoords,
                      destinationTitle: venueLocationName ?? "Selected Venue"
                    );
                  },
                  title: const Text("IOS Maps"),
                  leading: SvgPicture.asset(
                      "packages/map_launcher/assets/icons/apple.svg",
                      height: 30.0,
                      width: 30.0,
                    ),
                ),
                ListTile(
                    onTap: () {
                      FirebaseAnalyticsService.logUserUsesNavigation(eventId, "Google Maps");
                      Navigator.of(context).pop();
                      MapLauncher.showDirections(
                        mapType: MapType.google,
                        origin: originCoords,
                        originTitle: "Your location",
                        destination: destinationCoords,
                        destinationTitle: venueLocationName ?? "Selected Venue"
                      );
                    },
                    title: const Text("Google Maps"),
                    leading: SvgPicture.asset(
                      "packages/map_launcher/assets/icons/google.svg",
                      height: 30.0,
                      width: 30.0,
                    ),
                  ),
              ]
            )
          )
        );
      }
    );
  }
}

Apple Maps work fine, but Google Maps App does not open. As you can see, I send some events to FirebaseAnalytics to catch the list of installed Maps. Event though, I have Apple Maps and Google Maps I only get the Apple Maps :/

This is part of my Info.plist file:

<array>
    <string>comgooglemaps</string>
    <string>iosamap</string>
</array>

I did not find the way to test that on Simulator - cannot download the Google Maps App. Hence, I test that on my real device. Dart SDK version: 3.3.4 Flutter version: 3.19.6 Maybe I am doing something wrong here? Appreciate help :) Please, take a look in free time.

mattermoran commented 1 month ago

Could you try to clone the repo and run the example app to see if it works for you there? If it does then you just missing something in your code and if it doesn't then there's an issue somewhere but let's start by you testing the example app first.

niesamowityrycerz commented 1 month ago

@mattermoran I did as you suggested. I downloaded the example app on my device and I can successfully navigate using Google Map App. There must be something wrong with my code. 🤔 One more thing to mention here: when I click on on Google Maps(on the initial example app open) I was prompted If I would like to open Google Maps App. Thanks for your suggestion. I'll check my code.

niesamowityrycerz commented 1 month ago

Closing this issue as there is something wrong with my code.

mattermoran commented 1 month ago

Cool let me know if you can't figure out I'll help out debug