Skip to content

Commit

Permalink
Merge pull request #80 from heremaps/esd/1022
Browse files Browse the repository at this point in the history
ESD-1022: Update example apps for release 4.7.2.0
  • Loading branch information
datasun authored May 4, 2021
2 parents 5be0a31 + 337e26d commit 1886956
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ For an overview of the existing features, please check the _Developer's Guide_ f

> For now, the _Navigate Edition_ is only available upon request. Please contact your HERE representative to receive access including a set of evaluation credentials.
## List of Available Example Apps (Version 4.7.1.0)
## List of Available Example Apps (Version 4.7.2.0)
In this repository you can find the [latest example apps](examples/latest) that show key features of the HERE SDK in ready-to-use applications:

- **HelloMap**: Shows the classic 'Hello World'.
Expand Down
2 changes: 1 addition & 1 deletion examples/latest/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This folder contains the HERE SDK examples apps for version: 4.7.1.0
This folder contains the HERE SDK examples apps for version: 4.7.2.0

- HERE SDK for Android ([Lite Edition](lite/android/), [Explore Edition](explore/android/), [Navigate Edition](navigate/android/))
- HERE SDK for iOS ([Lite Edition](lite/ios/), [Explore Edition](explore/ios/), [Navigate Edition](navigate/ios/))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public NavigationExample(Context context, MapView mapView) {
throw new RuntimeException("Initialization of VisualNavigator failed: " + e.error.name());
}

// This enables a navigation view including a rendered navigation arrow.
visualNavigator.startRendering(mapView);

// A helper class for TTS.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,23 @@ public void onProgress(@NonNull RegionId regionId, int percentage) {
". Progress: " + percentage + "%.";
snackbar.setText(message).show();
}

@Override
public void onPause(@Nullable MapLoaderError mapLoaderError) {
if (mapLoaderError == null) {
String message = "The download was paused by the user calling mapDownloaderTask.pause().";
snackbar.setText(message).show();
} else {
String message = "Download regions onPause error. The task tried to often to retry the download: " + mapLoaderError;
snackbar.setText(message).show();
}
}

@Override
public void onResume() {
String message = "A previously paused download has been resumed.";
snackbar.setText(message).show();
}
});

mapDownloaderTasks.add(mapDownloaderTask);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class NavigationExample {
_visualNavigator.startRendering(_hereMapController);

// For easy testing, this location provider simulates location events along a route.
// You can use HERE positioning to feed real locations, see the positioning_app for an example.
// You can use HERE positioning to feed real locations, see the "Positioning"-section in
// our Developer's Guide for an example.
_locationProvider = new LocationProviderImplementation();

setupListeners();
Expand Down Expand Up @@ -76,21 +77,6 @@ class NavigationExample {
}

void setupListeners() {
// Notifies on the current map-matched location and other useful information while driving or walking.
// The map-matched location is used to update the map view.
_visualNavigator.navigableLocationListener = NavigableLocationListener.fromLambdas(
lambda_onNavigableLocationUpdated: (NavigableLocation currentNavigableLocation) {
MapMatchedLocation mapMatchedLocation = currentNavigableLocation.mapMatchedLocation;
if (mapMatchedLocation == null) {
print('This new location could not be map-matched. Are you off-road?');
return;
}

var speed = currentNavigableLocation.originalLocation.speedInMetersPerSecond;
var accuracy = currentNavigableLocation.originalLocation.speedAccuracyInMetersPerSecond;
print("Driving speed (m/s): $speed plus/minus an accuracy of: $accuracy");
});

// Notifies on the progress along the route including maneuver instructions.
// These maneuver instructions can be used to compose a visual representation of the next maneuver actions.
_visualNavigator.routeProgressListener =
Expand Down Expand Up @@ -147,6 +133,21 @@ class NavigationExample {
_previousManeuverIndex = nextManeuverIndex;
});

// Notifies on the current map-matched location and other useful information while driving or walking.
// The map-matched location is used to update the map view.
_visualNavigator.navigableLocationListener = NavigableLocationListener.fromLambdas(
lambda_onNavigableLocationUpdated: (NavigableLocation currentNavigableLocation) {
MapMatchedLocation mapMatchedLocation = currentNavigableLocation.mapMatchedLocation;
if (mapMatchedLocation == null) {
print('This new location could not be map-matched. Are you off-road?');
return;
}

var speed = currentNavigableLocation.originalLocation.speedInMetersPerSecond;
var accuracy = currentNavigableLocation.originalLocation.speedAccuracyInMetersPerSecond;
print("Driving speed (m/s): $speed plus/minus an accuracy of: $accuracy");
});

// Notifies when the destination of the route is reached.
_visualNavigator.destinationReachedListener =
DestinationReachedListener.fromLambdas(lambda_onDestinationReached: () {
Expand Down Expand Up @@ -253,7 +254,7 @@ class NavigationExample {
}

void setupVoiceTextMessages() {
LanguageCode languageCode = LanguageCode.enUs;
LanguageCode languageCode = LanguageCode.enGb;
List<LanguageCode> supportedVoiceSkins = VisualNavigator.getAvailableLanguagesForManeuverNotifications();
if (supportedVoiceSkins.contains(languageCode)) {
_visualNavigator.maneuverNotificationOptions = ManeuverNotificationOptions(languageCode, UnitSystem.metric);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ class OfflineMapsExample {
String message =
"Download of Switzerland. ID: " + regionId.id.toString() + ". Progress: " + percentage.toString() + "%.";
print(message);
}, lambda_onPause: (MapLoaderError mapLoaderError) {
if (mapLoaderError == null) {
_showDialog("Info", "The download was paused by the user calling mapDownloaderTask.pause().");
} else {
_showDialog("Error", "Download regions onPause error. The task tried to often to retry the download: $mapLoaderError");
}
}, lambda_onResume: () {
_showDialog("Info", "A previously paused download has been resumed.");
}));

_mapDownloaderTasks.add(mapDownloaderTask);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class RoutingExample {
HereMapController _hereMapController;
List<MapMarker> _mapMarkers = [];
List<MapPolyline> _mapPolylines = [];
RoutingInterface routingEngine;
RoutingInterface _routingEngine;
RoutingEngine _onlineRoutingEngine;
OfflineRoutingEngine _offlineRoutingEngine;
GeoCoordinates _startGeoCoordinates;
Expand All @@ -59,6 +59,9 @@ class RoutingExample {
} on InstantiationException {
throw ("Initialization of OfflineRoutingEngine failed.");
}

// Use _onlineRoutingEngine by default.
useOnlineRoutingEngine();
}

// Calculates a route with two waypoints (start / destination).
Expand All @@ -72,7 +75,7 @@ class RoutingExample {

List<Waypoint> waypoints = [startWaypoint, destinationWaypoint];

await _onlineRoutingEngine.calculateCarRoute(waypoints, CarOptions.withDefaults(),
await _routingEngine.calculateCarRoute(waypoints, CarOptions.withDefaults(),
(RoutingError routingError, List<here.Route> routeList) async {
if (routingError == null) {
here.Route route = routeList.first;
Expand Down Expand Up @@ -104,7 +107,7 @@ class RoutingExample {

List<Waypoint> waypoints = [startWaypoint, waypoint1, waypoint2, destinationWaypoint];

await _onlineRoutingEngine.calculateCarRoute(waypoints, CarOptions.withDefaults(),
await _routingEngine.calculateCarRoute(waypoints, CarOptions.withDefaults(),
(RoutingError routingError, List<here.Route> routeList) async {
if (routingError == null) {
here.Route route = routeList.first;
Expand All @@ -129,12 +132,12 @@ class RoutingExample {
}

void useOnlineRoutingEngine() {
routingEngine = _onlineRoutingEngine;
_routingEngine = _onlineRoutingEngine;
_showDialog('Switched to RoutingEngine', 'Routes will be calculated online.');
}

void useOfflineRoutingEngine() {
routingEngine = _offlineRoutingEngine;
_routingEngine = _offlineRoutingEngine;
// Note that this app does not show how to download offline maps. For this, check the offline_maps_app example.
_showDialog(
'Switched to OfflineRoutingEngine', 'Routes will be calculated offline on cached or downloaded map data.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ class OfflineMapsExample : DownloadRegionsStatusListener {
showMessage("Map download progress for Switzerland. ID: \(region.id). Progress: \(percentage)%.")
}

// Conform to the DownloadRegionsStatusListener protocol.
func onPause(error: MapLoaderError?) {
if (error == nil) {
showMessage("The download was paused by the user calling mapDownloaderTask.pause().")
} else {
showMessage("Download regions onPause error. The task tried to often to retry the download: \(error.debugDescription)")
}
}

// Conform to the DownloadRegionsStatusListener protocol.
func onResume() {
showMessage("A previously paused download has been resumed.")
}

// Finds a region in the downloaded region list.
// Note that we ignore children of children (and so on).
private func findRegion(localizedRegionName: String) -> Region? {
Expand Down

0 comments on commit 1886956

Please sign in to comment.