Skip to content

Commit 1886956

Browse files
authored
Merge pull request #80 from heremaps/esd/1022
ESD-1022: Update example apps for release 4.7.2.0
2 parents 5be0a31 + 337e26d commit 1886956

File tree

8 files changed

+68
-24
lines changed

8 files changed

+68
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ For an overview of the existing features, please check the _Developer's Guide_ f
2121

2222
> For now, the _Navigate Edition_ is only available upon request. Please contact your HERE representative to receive access including a set of evaluation credentials.
2323
24-
## List of Available Example Apps (Version 4.7.1.0)
24+
## List of Available Example Apps (Version 4.7.2.0)
2525
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:
2626

2727
- **HelloMap**: Shows the classic 'Hello World'.

examples/latest/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
This folder contains the HERE SDK examples apps for version: 4.7.1.0
1+
This folder contains the HERE SDK examples apps for version: 4.7.2.0
22

33
- HERE SDK for Android ([Lite Edition](lite/android/), [Explore Edition](explore/android/), [Navigate Edition](navigate/android/))
44
- HERE SDK for iOS ([Lite Edition](lite/ios/), [Explore Edition](explore/ios/), [Navigate Edition](navigate/ios/))

examples/latest/navigate/android/Navigation/app/src/main/java/com/here/navigation/NavigationExample.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ public NavigationExample(Context context, MapView mapView) {
109109
throw new RuntimeException("Initialization of VisualNavigator failed: " + e.error.name());
110110
}
111111

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

114115
// A helper class for TTS.

examples/latest/navigate/android/OfflineMaps/app/src/main/java/com/here/offlinemaps/OfflineMapsExample.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,23 @@ public void onProgress(@NonNull RegionId regionId, int percentage) {
164164
". Progress: " + percentage + "%.";
165165
snackbar.setText(message).show();
166166
}
167+
168+
@Override
169+
public void onPause(@Nullable MapLoaderError mapLoaderError) {
170+
if (mapLoaderError == null) {
171+
String message = "The download was paused by the user calling mapDownloaderTask.pause().";
172+
snackbar.setText(message).show();
173+
} else {
174+
String message = "Download regions onPause error. The task tried to often to retry the download: " + mapLoaderError;
175+
snackbar.setText(message).show();
176+
}
177+
}
178+
179+
@Override
180+
public void onResume() {
181+
String message = "A previously paused download has been resumed.";
182+
snackbar.setText(message).show();
183+
}
167184
});
168185

169186
mapDownloaderTasks.add(mapDownloaderTask);

examples/latest/navigate/flutter/navigation_app/lib/NavigationExample.dart

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ class NavigationExample {
4747
_visualNavigator.startRendering(_hereMapController);
4848

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

5354
setupListeners();
@@ -76,21 +77,6 @@ class NavigationExample {
7677
}
7778

7879
void setupListeners() {
79-
// Notifies on the current map-matched location and other useful information while driving or walking.
80-
// The map-matched location is used to update the map view.
81-
_visualNavigator.navigableLocationListener = NavigableLocationListener.fromLambdas(
82-
lambda_onNavigableLocationUpdated: (NavigableLocation currentNavigableLocation) {
83-
MapMatchedLocation mapMatchedLocation = currentNavigableLocation.mapMatchedLocation;
84-
if (mapMatchedLocation == null) {
85-
print('This new location could not be map-matched. Are you off-road?');
86-
return;
87-
}
88-
89-
var speed = currentNavigableLocation.originalLocation.speedInMetersPerSecond;
90-
var accuracy = currentNavigableLocation.originalLocation.speedAccuracyInMetersPerSecond;
91-
print("Driving speed (m/s): $speed plus/minus an accuracy of: $accuracy");
92-
});
93-
9480
// Notifies on the progress along the route including maneuver instructions.
9581
// These maneuver instructions can be used to compose a visual representation of the next maneuver actions.
9682
_visualNavigator.routeProgressListener =
@@ -147,6 +133,21 @@ class NavigationExample {
147133
_previousManeuverIndex = nextManeuverIndex;
148134
});
149135

136+
// Notifies on the current map-matched location and other useful information while driving or walking.
137+
// The map-matched location is used to update the map view.
138+
_visualNavigator.navigableLocationListener = NavigableLocationListener.fromLambdas(
139+
lambda_onNavigableLocationUpdated: (NavigableLocation currentNavigableLocation) {
140+
MapMatchedLocation mapMatchedLocation = currentNavigableLocation.mapMatchedLocation;
141+
if (mapMatchedLocation == null) {
142+
print('This new location could not be map-matched. Are you off-road?');
143+
return;
144+
}
145+
146+
var speed = currentNavigableLocation.originalLocation.speedInMetersPerSecond;
147+
var accuracy = currentNavigableLocation.originalLocation.speedAccuracyInMetersPerSecond;
148+
print("Driving speed (m/s): $speed plus/minus an accuracy of: $accuracy");
149+
});
150+
150151
// Notifies when the destination of the route is reached.
151152
_visualNavigator.destinationReachedListener =
152153
DestinationReachedListener.fromLambdas(lambda_onDestinationReached: () {
@@ -253,7 +254,7 @@ class NavigationExample {
253254
}
254255

255256
void setupVoiceTextMessages() {
256-
LanguageCode languageCode = LanguageCode.enUs;
257+
LanguageCode languageCode = LanguageCode.enGb;
257258
List<LanguageCode> supportedVoiceSkins = VisualNavigator.getAvailableLanguagesForManeuverNotifications();
258259
if (supportedVoiceSkins.contains(languageCode)) {
259260
_visualNavigator.maneuverNotificationOptions = ManeuverNotificationOptions(languageCode, UnitSystem.metric);

examples/latest/navigate/flutter/offline_maps_app/lib/OfflineMapsExample.dart

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ class OfflineMapsExample {
135135
String message =
136136
"Download of Switzerland. ID: " + regionId.id.toString() + ". Progress: " + percentage.toString() + "%.";
137137
print(message);
138+
}, lambda_onPause: (MapLoaderError mapLoaderError) {
139+
if (mapLoaderError == null) {
140+
_showDialog("Info", "The download was paused by the user calling mapDownloaderTask.pause().");
141+
} else {
142+
_showDialog("Error", "Download regions onPause error. The task tried to often to retry the download: $mapLoaderError");
143+
}
144+
}, lambda_onResume: () {
145+
_showDialog("Info", "A previously paused download has been resumed.");
138146
}));
139147

140148
_mapDownloaderTasks.add(mapDownloaderTask);

examples/latest/navigate/flutter/routing_hybrid_app/lib/RoutingExample.dart

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class RoutingExample {
3333
HereMapController _hereMapController;
3434
List<MapMarker> _mapMarkers = [];
3535
List<MapPolyline> _mapPolylines = [];
36-
RoutingInterface routingEngine;
36+
RoutingInterface _routingEngine;
3737
RoutingEngine _onlineRoutingEngine;
3838
OfflineRoutingEngine _offlineRoutingEngine;
3939
GeoCoordinates _startGeoCoordinates;
@@ -59,6 +59,9 @@ class RoutingExample {
5959
} on InstantiationException {
6060
throw ("Initialization of OfflineRoutingEngine failed.");
6161
}
62+
63+
// Use _onlineRoutingEngine by default.
64+
useOnlineRoutingEngine();
6265
}
6366

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

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

75-
await _onlineRoutingEngine.calculateCarRoute(waypoints, CarOptions.withDefaults(),
78+
await _routingEngine.calculateCarRoute(waypoints, CarOptions.withDefaults(),
7679
(RoutingError routingError, List<here.Route> routeList) async {
7780
if (routingError == null) {
7881
here.Route route = routeList.first;
@@ -104,7 +107,7 @@ class RoutingExample {
104107

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

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

131134
void useOnlineRoutingEngine() {
132-
routingEngine = _onlineRoutingEngine;
135+
_routingEngine = _onlineRoutingEngine;
133136
_showDialog('Switched to RoutingEngine', 'Routes will be calculated online.');
134137
}
135138

136139
void useOfflineRoutingEngine() {
137-
routingEngine = _offlineRoutingEngine;
140+
_routingEngine = _offlineRoutingEngine;
138141
// Note that this app does not show how to download offline maps. For this, check the offline_maps_app example.
139142
_showDialog(
140143
'Switched to OfflineRoutingEngine', 'Routes will be calculated offline on cached or downloaded map data.');

examples/latest/navigate/ios/OfflineMaps/OfflineMaps/OfflineMapsExample.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,20 @@ class OfflineMapsExample : DownloadRegionsStatusListener {
121121
showMessage("Map download progress for Switzerland. ID: \(region.id). Progress: \(percentage)%.")
122122
}
123123

124+
// Conform to the DownloadRegionsStatusListener protocol.
125+
func onPause(error: MapLoaderError?) {
126+
if (error == nil) {
127+
showMessage("The download was paused by the user calling mapDownloaderTask.pause().")
128+
} else {
129+
showMessage("Download regions onPause error. The task tried to often to retry the download: \(error.debugDescription)")
130+
}
131+
}
132+
133+
// Conform to the DownloadRegionsStatusListener protocol.
134+
func onResume() {
135+
showMessage("A previously paused download has been resumed.")
136+
}
137+
124138
// Finds a region in the downloaded region list.
125139
// Note that we ignore children of children (and so on).
126140
private func findRegion(localizedRegionName: String) -> Region? {

0 commit comments

Comments
 (0)