Skip to content

Commit

Permalink
feat: add support for tomtom go fleet & Sygic Truck (#158)
Browse files Browse the repository at this point in the history
  • Loading branch information
amrahmed242 authored Sep 2, 2023
1 parent 9ba241e commit cb89f7b
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 3 deletions.
3 changes: 3 additions & 0 deletions android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<package android:name="com.here.app.maps" />
<package android:name="com.huawei.maps.app" />
<package android:name="com.alk.copilot.mapviewer" />
<package android:name="com.tomtom.gplay.navapp"/>
<package android:name="com.tomtom.gplay.navapp.gofleet"/>
<package android:name="com.sygic.truck"/>
</queries>

</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import io.flutter.plugin.common.PluginRegistry.Registrar

private enum class MapType { google, googleGo, amap, baidu, waze, yandexNavi, yandexMaps, citymapper, mapswithme, osmand, osmandplus, doubleGis, tencent, here, petal, tomtomgo, copilot }
private enum class MapType { google, googleGo, amap, baidu, waze, yandexNavi, yandexMaps, citymapper, mapswithme, osmand, osmandplus, doubleGis, tencent, here, petal, tomtomgo, copilot, sygic, tomtomgofleet }

private class MapModel(val mapType: MapType, val mapName: String, val packageName: String) {
fun toMap(): Map<String, String> {
Expand Down Expand Up @@ -56,6 +56,8 @@ class MapLauncherPlugin : FlutterPlugin, MethodCallHandler {
MapModel(MapType.here, "HERE WeGo", "com.here.app.maps"),
MapModel(MapType.petal, "Petal Maps", "com.huawei.maps.app"),
MapModel(MapType.tomtomgo, "TomTom Go", "com.tomtom.gplay.navapp"),
MapModel(MapType.tomtomgofleet, "TomTom Go Fleet", "com.tomtom.gplay.navapp.gofleet"),
MapModel(MapType.sygic, "Sygic Truck", "com.sygic.truck"),
MapModel(MapType.copilot, "CoPilot", "com.alk.copilot.mapviewer")
)

Expand Down
1 change: 1 addition & 0 deletions assets/icons/sygic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions assets/icons/tomtomgofleet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
<string>qqmap</string>
<string>here-location</string>
<string>copilot</string>
<string>tomtomgo</string>
<string>com.sygic.aura</string>
</array>
</dict>
</plist>
4 changes: 4 additions & 0 deletions ios/Classes/SwiftMapLauncherPlugin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ private enum MapType: String {
case tencent
case here
case tomtomgo
case tomtomgofleet
case copilot
case sygic

func type() -> String {
return self.rawValue
Expand Down Expand Up @@ -60,6 +62,8 @@ private let maps: [Map] = [
Map(mapName: "Tencent (QQ Maps)", mapType: MapType.tencent, urlPrefix: "qqmap://"),
Map(mapName: "HERE WeGo", mapType: MapType.here, urlPrefix: "here-location://"),
Map(mapName: "TomTom Go", mapType: MapType.tomtomgo, urlPrefix: "tomtomgo://"),
Map(mapName: "TomTom Go Fleet", mapType: MapType.tomtomgofleet, urlPrefix: "tomtomgofleet://"),
Map(mapName: "Sygic Truck", mapType: MapType.sygic, urlPrefix: "com.sygic.aura://"),
Map(mapName: "CoPilot", mapType: MapType.copilot, urlPrefix: "copilot://")
]

Expand Down
26 changes: 25 additions & 1 deletion lib/src/directions_url.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:io';

import 'package:map_launcher/src/models.dart';
import 'package:map_launcher/src/utils.dart';

Expand Down Expand Up @@ -241,7 +242,6 @@ String getMapDirectionsUrl({
},
// the TomTom Go app cannot handle the ? at the start of the query
).replaceFirst('?', '');

case MapType.copilot:
// Documentation:
// https://developer.trimblemaps.com/copilot-navigation/v10-19/feature-guide/advanced-features/url-launch/
Expand All @@ -256,5 +256,29 @@ String getMapDirectionsUrl({
...(extraParams ?? {}),
},
);
case MapType.tomtomgofleet:
return Utils.buildUrl(
url: 'google.navigation:',
queryParams: {
'q': '${destination.latitude},${destination.longitude}',
...(extraParams ?? {}),
},
// the TomTom Go app cannot handle the ? at the start of the query
).replaceFirst('?', '');
case MapType.sygic:
// Documentation:
// https://www.sygic.com/developers/professional-navigation-sdk/introduction
String url = Utils.buildUrl(
url:
'com.sygic.aura://coordinate|${destination.longitude}|${destination.latitude}|drive',
queryParams: {
...(extraParams ?? {}),
},
);
print(url);
print(url);
print(url);
print(url);
return url;
}
}
21 changes: 20 additions & 1 deletion lib/src/marker_url.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:io';

import 'package:map_launcher/src/models.dart';
import 'package:map_launcher/src/utils.dart';

Expand Down Expand Up @@ -222,7 +223,6 @@ String getMapMarkerUrl({
...(extraParams ?? {}),
},
);

case MapType.copilot:
// Documentation:
// https://developer.trimblemaps.com/copilot-navigation/v10-19/feature-guide/advanced-features/url-launch/
Expand All @@ -236,5 +236,24 @@ String getMapMarkerUrl({
...(extraParams ?? {}),
},
);
case MapType.tomtomgofleet:
return Utils.buildUrl(
url: 'geo:${coords.latitude},${coords.longitude}',
queryParams: {
'q':
'${coords.latitude},${coords.longitude}${title != null && title.isNotEmpty ? '($title)' : ''}',
...(extraParams ?? {}),
},
);
case MapType.sygic:
// Documentation:
// https://www.sygic.com/developers/professional-navigation-sdk/introduction
return Utils.buildUrl(
url:
'com.sygic.aura://coordinate|${coords.longitude}|${coords.latitude}|show',
queryParams: {
...(extraParams ?? {}),
},
);
}
}
2 changes: 2 additions & 0 deletions lib/src/models.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ enum MapType {
petal,
tomtomgo,
copilot,
tomtomgofleet,
sygic
}

/// Defines the supported modes of transportation for [showDirections]
Expand Down

0 comments on commit cb89f7b

Please sign in to comment.