mattermoran / map_launcher

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

iOS crash when using unsupported MapTypes #83

Closed bridystone closed 3 years ago

bridystone commented 3 years ago

Using unsupported maptypes on iOS (osmandplus / googlego) causes the whole Flutter App to crash. This is because there is no equivalent to the Dart MapType in the Swift Applicaiton.

Maybe the easiest way to fix this is to create dummyURL types. Either with fallback to google/osm or create a urlPrefix: "dummy://"

i.e.

private enum MapType: String {
...
  case googleGo
  case osmandplus
...
}
...
private let maps: [Map] = [
...
  Map(mapName: "Google Maps Go", mapType: MapType.googleGo, urlPrefix: "comgooglemaps://"),
  Map(mapName: "OsmAnd+", mapType: MapType.osmandplus, urlPrefix: "osmandmaps://"),
...
mattermoran commented 3 years ago

You're right, totally forgot about that. It seems to be failing in the getMapByRawMapType method. image We could make it return optional Map so we don't need to force unwrap and then isMapAvailable method would return false if nil

I think it's probably cleaner than adding those maps into ios list. The issue with fallback to google/osm is that if google maps is available then google maps go would also show up same for osmand which is not what we want.

Let me know if you think otherwise

bridystone commented 3 years ago

Fallback-Issue: valid point. I didn't of that.

At least it now seems to work for me :)

mattermoran commented 3 years ago

Released v.2.1.1 with your fix. Cheers! :)