mattermoran / map_launcher

Flutter plugin for launching maps
MIT License
265 stars 125 forks source link

Not Launching Maps #4

Closed azamsharp closed 4 years ago

azamsharp commented 4 years ago

I am using the following code and trying to launch it on iOS simulator. I made all the necessary changes in info.plist file. No errors are shown. It just does not open the map.

import 'package:map_launcher/map_launcher.dart' as ml;
Future<void> _openMaps(PlaceViewModel vm) async {
     if(await ml.MapLauncher.isMapAvailable(ml.MapType.google)) {
       await ml.MapLauncher.launchMap(
         mapType: ml.MapType.google, 
         coords: ml.Coords(vm.latitude,vm.longitude), 
         title: vm.name, 
         description: vm.name 
       );
     } else if(await ml.MapLauncher.isMapAvailable(ml.MapType.apple)) {
       await ml.MapLauncher.launchMap(
         mapType: ml.MapType.google, 
         coords: ml.Coords(vm.latitude,vm.longitude), 
         title: vm.name, 
         description: vm.name
       );
     }
  }```

The _openMaps is called based on the ListTitle selection of a placeList widget. 
This is the code for homePage.dart file which contains PlaceList widget. 

onPressed: () { showModalBottomSheet( context: context, builder: (context) => PlaceList(places: vm.places, onSelected: _openMaps,) ); }

azamsharp commented 4 years ago

Found the issue. I was passing MapType.google when MapType was apple. An error would be helpful in this scenario.

mattermoran commented 4 years ago

Hi. You're right, I'll make sure it throws an exception

mattermoran commented 4 years ago

Version 0.3.1 should be throwing a platform exception if map is not available

mattermoran commented 4 years ago

Fixed in https://github.com/mattermoran/map_launcher/commit/a24254ea3ba554d04f9b8ca064e2c7ee1fc7fbe7