Skip to content

Commit

Permalink
Merge pull request #333 from heremaps/esd/41930
Browse files Browse the repository at this point in the history
Update example apps for release 4.19.3.0
  • Loading branch information
maharudraabhishek authored Aug 2, 2024
2 parents 03846bb + 0255129 commit 5ef88aa
Show file tree
Hide file tree
Showing 53 changed files with 1,638 additions and 330 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ For an overview of the existing features, please check the _Developer Guide_ for

> 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.19.2.0)
## List of Available Example Apps (Version 4.19.3.0)

- **HelloMap**: Shows the classic 'Hello World'.
- **HelloMapKotlin**: Shows the classic 'Hello World' using Kotlin language (Android only).
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.19.2.0
This folder contains the HERE SDK examples apps for version: 4.19.3.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 @@ -106,15 +106,16 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
}

private void loadMapScene() {
// The camera can be configured before or after a scene is loaded.
double distanceInMeters = 1000 * 10;
MapMeasure mapMeasureZoom = new MapMeasure(MapMeasure.Kind.DISTANCE, distanceInMeters);
mapView.getCamera().lookAt(new GeoCoordinates(52.530932, 13.384915), mapMeasureZoom);

// Load a scene from the HERE SDK to render the map with a map scheme.
mapView.getMapScene().loadScene(MapScheme.NORMAL_DAY, new MapScene.LoadSceneCallback() {
@Override
public void onLoadScene(@Nullable MapError mapError) {
if (mapError == null) {
double distanceInMeters = 1000 * 10;
MapMeasure mapMeasureZoom = new MapMeasure(MapMeasure.Kind.DISTANCE, distanceInMeters);
mapView.getCamera().lookAt(new GeoCoordinates(52.530932, 13.384915), mapMeasureZoom);
} else {
if (mapError != null) {
Log.d(TAG, "Loading map failed: mapError: " + mapError.name());
}
}
Expand Down Expand Up @@ -145,7 +146,7 @@ protected void onSaveInstanceState(@NonNull Bundle outState) {
mapView.onSaveInstanceState(outState);
super.onSaveInstanceState(outState);
}

private void disposeHERESDK() {
// Free HERE SDK resources before the application shuts down.
// Usually, this should be called only on application termination.
Expand Down
11 changes: 6 additions & 5 deletions examples/latest/explore/flutter/hello_map_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,16 @@ class MyApp extends StatelessWidget {
}

void _onMapCreated(HereMapController hereMapController) {
// The camera can be configured before or after a scene is loaded.
const double distanceToEarthInMeters = 8000;
MapMeasure mapMeasureZoom = MapMeasure(MapMeasureKind.distance, distanceToEarthInMeters);
hereMapController.camera.lookAtPointWithMeasure(GeoCoordinates(52.530932, 13.384915), mapMeasureZoom);

// Load the map scene using a map scheme to render the map with.
hereMapController.mapScene.loadSceneForMapScheme(MapScheme.normalDay, (MapError? error) {
if (error != null) {
print('Map scene not loaded. MapError: ${error.toString()}');
return;
}

const double distanceToEarthInMeters = 8000;
MapMeasure mapMeasureZoom = MapMeasure(MapMeasureKind.distance, distanceToEarthInMeters);
hereMapController.camera.lookAtPointWithMeasure(GeoCoordinates(52.530932, 13.384915), mapMeasureZoom);
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,28 @@ import UIKit
class ViewController: UIViewController {

var mapView : MapView!

override func viewDidLoad() {
super.viewDidLoad()

// Initialize MapView without a storyboard.
mapView = MapView(frame: view.bounds)
view.addSubview(mapView)

// The camera can be configured before or after a scene is loaded.
let camera = mapView.camera
let distanceInMeters = MapMeasure(kind: .distance, value: 1000 * 10)
camera.lookAt(point: GeoCoordinates(latitude: 52.518043, longitude: 13.405991), zoom: distanceInMeters)

// Load the map scene using a map scheme to render the map with.
mapView.mapScene.loadScene(mapScheme: MapScheme.normalDay, completion: onLoadScene)
}

// Completion handler when loading a map scene.
private func onLoadScene(mapError: MapError?) {
guard mapError == nil else {
print("Error: Map scene not loaded, \(String(describing: mapError))")
return
if let error = mapError {
print("Error: Map scene not loaded, \(error)")
}

// Configure the map.
let camera = mapView.camera
let distanceInMeters = MapMeasure(kind: .distance, value: 1000 * 10)
camera.lookAt(point: GeoCoordinates(latitude: 52.518043, longitude: 13.405991), zoom: distanceInMeters)
}

override func didReceiveMemoryWarning() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
<device id="retina4_7" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="Stack View standard spacing" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
Expand All @@ -21,12 +19,24 @@
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="jv9-0R-Tz9" customClass="MapView" customModule="heresdk">
<rect key="frame" x="0.0" y="20" width="375" height="647"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="yhR-d4-nO0">
<rect key="frame" x="8" y="53" width="170" height="34"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="0.0" green="0.71372549019999998" blue="0.69803921570000005" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Traffic Optimization -On "/>
<connections>
<action selector="toggleTraffic:" destination="BYZ-38-t0r" eventType="touchUpInside" id="GOB-VV-rkF"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</view>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" spacingType="standard" translatesAutoresizingMaskIntoConstraints="NO" id="eu1-QJ-vBV">
<rect key="frame" x="8" y="28" width="359" height="30"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="9Bv-Tp-mIo">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="9Bv-Tp-mIo">
<rect key="frame" x="0.0" y="0.0" width="114.5" height="30"/>
<color key="backgroundColor" red="0.0" green="0.71372549019607845" blue="0.69803921568627447" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand All @@ -35,7 +45,7 @@
<action selector="onAddRouteButtonClicked:" destination="BYZ-38-t0r" eventType="touchUpInside" id="dMJ-B7-5zw"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IDY-a8-cO4">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="IDY-a8-cO4">
<rect key="frame" x="122.5" y="0.0" width="114" height="30"/>
<color key="backgroundColor" red="0.0" green="0.71372549019607845" blue="0.69803921568627447" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand All @@ -44,7 +54,7 @@
<action selector="onAddWaypointsButtonClicked:" destination="BYZ-38-t0r" eventType="touchUpInside" id="TbN-U1-8lZ"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dqL-zX-9qE">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="dqL-zX-9qE">
<rect key="frame" x="244.5" y="0.0" width="114.5" height="30"/>
<color key="backgroundColor" red="0.0" green="0.71372549019607845" blue="0.69803921568627447" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="tintColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
Expand All @@ -59,6 +69,7 @@
</constraints>
</stackView>
</subviews>
<viewLayoutGuide key="safeArea" id="7yx-63-l25"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="eu1-QJ-vBV" firstAttribute="top" secondItem="7yx-63-l25" secondAttribute="top" constant="8" id="1NJ-EX-MTG"/>
Expand All @@ -69,7 +80,6 @@
<constraint firstItem="jv9-0R-Tz9" firstAttribute="leading" secondItem="d7N-t3-PMt" secondAttribute="leading" id="qOE-QK-qnt"/>
<constraint firstItem="7yx-63-l25" firstAttribute="trailing" secondItem="eu1-QJ-vBV" secondAttribute="trailing" constant="8" id="xbd-jw-H4Z"/>
</constraints>
<viewLayoutGuide key="safeArea" id="7yx-63-l25"/>
</view>
<connections>
<outlet property="mapView" destination="jv9-0R-Tz9" id="NWv-T2-utS"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public void clearMapButtonClicked(View view) {
routingExample.clearMap();
}

public void toggleTrafficOptimization(View view) {
routingExample.toggleTrafficOptimization();
}
@Override
protected void onPause() {
mapView.onPause();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import com.here.sdk.routing.RoutingEngine;
import com.here.sdk.routing.RoutingError;
import com.here.sdk.routing.Section;
import com.here.sdk.routing.TrafficOptimizationMode;
import com.here.sdk.routing.Waypoint;

import java.util.ArrayList;
Expand All @@ -63,6 +64,7 @@ public class RoutingExample {
private RoutingEngine routingEngine;
private GeoCoordinates startGeoCoordinates;
private GeoCoordinates destinationGeoCoordinates;
private boolean trafficDisabled;

public RoutingExample(Context context, MapViewLite mapView) {
this.context = context;
Expand All @@ -89,7 +91,7 @@ public void addRoute() {

routingEngine.calculateRoute(
waypoints,
new CarOptions(),
getCarOptions(),
new CalculateRouteCallback() {
@Override
public void onRouteCalculated(@Nullable RoutingError routingError, @Nullable List<Route> routes) {
Expand All @@ -106,10 +108,12 @@ public void onRouteCalculated(@Nullable RoutingError routingError, @Nullable Lis

private void showRouteDetails(Route route) {
long estimatedTravelTimeInSeconds = route.getDuration().getSeconds();
long estimatedTrafficDelayInSeconds = route.getTrafficDelay().getSeconds();
int lengthInMeters = route.getLengthInMeters();

String routeDetails =
"Travel Time: " + formatTime(estimatedTravelTimeInSeconds)
+ ", Traffic delay: " + formatTime(estimatedTrafficDelayInSeconds)
+ ", Length: " + formatLength(lengthInMeters);

showDialog("Route Details", routeDetails);
Expand Down Expand Up @@ -158,6 +162,21 @@ private void showRouteOnMap(Route route) {
}
}

public void toggleTrafficOptimization() {
trafficDisabled = !trafficDisabled;
}

private CarOptions getCarOptions() {
CarOptions carOptions = new CarOptions();
carOptions.routeOptions.enableTolls = true;
// Disabled - Traffic optimization is completely disabled, including long-term road closures. It helps in producing stable routes.
// Time dependent - Traffic optimization is enabled, the shape of the route will be adjusted according to the traffic situation which depends on departure time and arrival time.
carOptions.routeOptions.trafficOptimizationMode = trafficDisabled ?
TrafficOptimizationMode.DISABLED :
TrafficOptimizationMode.TIME_DEPENDENT;
return carOptions;
}

private void logManeuverInstructions(Section section) {
Log.d(TAG, "Log maneuver instructions per route section:");
List<Maneuver> maneuverInstructions = section.getManeuvers();
Expand Down Expand Up @@ -185,7 +204,7 @@ public void addWaypoints() {

routingEngine.calculateRoute(
waypoints,
new CarOptions(),
getCarOptions(),
new CalculateRouteCallback() {
@Override
public void onRouteCalculated(@Nullable RoutingError routingError, @Nullable List<Route> routes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/firstRow"
android:orientation="horizontal">
<Button
android:layout_width="0dp"
Expand All @@ -39,5 +40,19 @@
android:text="Clear Map"
android:onClick="clearMapButtonClicked" />
</LinearLayout>
<LinearLayout
app:layout_constraintTop_toBottomOf="@id/firstRow"
app:layout_constraintStart_toStartOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ToggleButton
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textOff="Traffic optimization -On"
android:textOn="Traffic optimization -Off"
android:onClick="toggleTrafficOptimization" />
</LinearLayout>

</android.support.constraint.ConstraintLayout>
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,16 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis
}

private void loadMapScene() {
// The camera can be configured before or after a scene is loaded.
double distanceInMeters = 1000 * 10;
MapMeasure mapMeasureZoom = new MapMeasure(MapMeasure.Kind.DISTANCE, distanceInMeters);
mapView.getCamera().lookAt(new GeoCoordinates(52.530932, 13.384915), mapMeasureZoom);

// Load a scene from the HERE SDK to render the map with a map scheme.
mapView.getMapScene().loadScene(MapScheme.NORMAL_DAY, new MapScene.LoadSceneCallback() {
@Override
public void onLoadScene(@Nullable MapError mapError) {
if (mapError == null) {
double distanceInMeters = 1000 * 10;
MapMeasure mapMeasureZoom = new MapMeasure(MapMeasure.Kind.DISTANCE, distanceInMeters);
mapView.getCamera().lookAt(new GeoCoordinates(52.530932, 13.384915), mapMeasureZoom);
} else {
if (mapError != null) {
Log.d(TAG, "Loading map failed: mapError: " + mapError.name());
}
}
Expand Down Expand Up @@ -145,7 +146,7 @@ protected void onSaveInstanceState(@NonNull Bundle outState) {
mapView.onSaveInstanceState(outState);
super.onSaveInstanceState(outState);
}

private void disposeHERESDK() {
// Free HERE SDK resources before the application shuts down.
// Usually, this should be called only on application termination.
Expand Down
Loading

0 comments on commit 5ef88aa

Please sign in to comment.