diff --git a/README.md b/README.md index 5e555597..69ab80e3 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,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.11.4.0) +## List of Available Example Apps (Version 4.12.0.0) - **HelloMap**: Shows the classic 'Hello World'. - **HelloMapKotlin**: Shows the classic 'Hello World' using Kotlin language (Android only). diff --git a/examples/latest/README.md b/examples/latest/README.md index 864f5c09..64afbc3f 100644 --- a/examples/latest/README.md +++ b/examples/latest/README.md @@ -1,4 +1,4 @@ -This folder contains the HERE SDK examples apps for version: 4.11.4.0 +This folder contains the HERE SDK examples apps for version: 4.12.0.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/)) diff --git a/examples/latest/explore/android/Camera/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/Camera/app/src/main/AndroidManifest.xml index 98c09285..9c2c3777 100644 --- a/examples/latest/explore/android/Camera/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/Camera/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/Camera/app/src/main/java/com/here/sdk/camera/MainActivity.java b/examples/latest/explore/android/Camera/app/src/main/java/com/here/sdk/camera/MainActivity.java index bb75be9e..7130aba0 100644 --- a/examples/latest/explore/android/Camera/app/src/main/java/com/here/sdk/camera/MainActivity.java +++ b/examples/latest/explore/android/Camera/app/src/main/java/com/here/sdk/camera/MainActivity.java @@ -96,25 +96,27 @@ public void moveToXYButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/AndroidManifest.xml index 5510c41b..e5f7438e 100644 --- a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> @@ -27,4 +28,4 @@ - \ No newline at end of file + diff --git a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/CameraKeyframeTracksExample.java b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/CameraKeyframeTracksExample.java index 3e4d1d76..842e722a 100644 --- a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/CameraKeyframeTracksExample.java +++ b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/CameraKeyframeTracksExample.java @@ -21,9 +21,11 @@ import android.util.Log; -import com.here.camerakeyframetracks.models.LocationKeyframeModel; -import com.here.camerakeyframetracks.models.OrientationKeyframeModel; -import com.here.camerakeyframetracks.models.ScalarKeyframeModel; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.here.sdk.animation.AnimationListener; +import com.here.sdk.animation.AnimationState; import com.here.sdk.animation.EasingFunction; import com.here.sdk.animation.GeoCoordinatesKeyframe; import com.here.sdk.animation.GeoOrientationKeyframe; @@ -43,128 +45,145 @@ public class CameraKeyframeTracksExample { + private static final String TAG = CameraKeyframeTracksExample.class.getName(); + private final MapView mapView; - private List tracks = new ArrayList<>(); public CameraKeyframeTracksExample(MapView mapView) { this.mapView = mapView; } public void startTripToNYC() { - // This animation can be started and replayed. When started, it will always start from globe view. - List tracks = createTripToNYCAnimation(); - startTripToNYCAnimation(tracks); + List mapCameraKeyframeTracks = createMapCameraKeyframeTracks(); + + MapCameraAnimation mapCameraAnimation; + + try { + mapCameraAnimation = MapCameraAnimationFactory.createAnimation(mapCameraKeyframeTracks); + } catch (MapCameraAnimation.InstantiationException e) { + Log.e(TAG, e.error.name()); + return; + } + + // This animation can be started and replayed. When started, it will always start from the first keyframe. + mapView.getCamera().startAnimation(mapCameraAnimation, new AnimationListener() { + @Override + public void onAnimationStateChanged(@NonNull AnimationState animationState) { + switch (animationState) { + case STARTED: + Log.d(TAG, "Animation started."); + break; + case CANCELLED: + Log.d(TAG, "Animation cancelled."); + break; + case COMPLETED: + Log.d(TAG, "Animation finished."); + break; + } + } + }); } public void stopTripToNYCAnimation() { mapView.getCamera().cancelAnimations(); } - private List createLocationsForTripToNYC() { - List locationList = new ArrayList<>(); + @Nullable + private List createMapCameraKeyframeTracks() { + MapCameraKeyframeTrack geoCoordinatesMapCameraKeyframeTrack; + MapCameraKeyframeTrack scalarMapCameraKeyframeTrack; + MapCameraKeyframeTrack geoOrientationMapCameraKeyframeTrack; - Collections.addAll( - locationList, - new LocationKeyframeModel(new GeoCoordinates(40.685869754854544, -74.02550202768754), Duration.ofMillis(0)), // Statue of Liberty - new LocationKeyframeModel(new GeoCoordinates(40.69051652745291, -74.04455943649657), Duration.ofMillis(5000)), // Statue of Liberty - new LocationKeyframeModel(new GeoCoordinates(40.69051652745291, -74.04455943649657), Duration.ofMillis(7000)), // Statue of Liberty - new LocationKeyframeModel(new GeoCoordinates(40.69051652745291, -74.04455943649657), Duration.ofMillis(9000)), // Statue of Liberty - new LocationKeyframeModel(new GeoCoordinates(40.690266839135, -74.01237515471776), Duration.ofMillis(5000)), // Governor Island - new LocationKeyframeModel(new GeoCoordinates(40.7116777285189, -74.01248494562448), Duration.ofMillis(6000)), // World Trade Center - new LocationKeyframeModel(new GeoCoordinates(40.71083291395444, -74.01226399217569), Duration.ofMillis(6000)), // World Trade Center - new LocationKeyframeModel(new GeoCoordinates(40.719259512385506, -74.01171007254635), Duration.ofMillis(5000)), // Manhattan College - new LocationKeyframeModel(new GeoCoordinates(40.73603959180013, -73.98968489844603), Duration.ofMillis(6000)), // Union Square - new LocationKeyframeModel(new GeoCoordinates(40.741732824650214, -73.98825255774022), Duration.ofMillis(5000)), // Flatiron - new LocationKeyframeModel(new GeoCoordinates(40.74870637098952, -73.98515306630678), Duration.ofMillis(6000)), // Empire State Building - new LocationKeyframeModel(new GeoCoordinates(40.742693509776856, -73.95937093336781), Duration.ofMillis(3000)), // Queens Midtown - new LocationKeyframeModel(new GeoCoordinates(40.75065611103842, -73.96053139022635), Duration.ofMillis(4000)), // Roosevelt Island - new LocationKeyframeModel(new GeoCoordinates(40.756823163883794, -73.95461519921352), Duration.ofMillis(4000)), // Queens Bridge - new LocationKeyframeModel(new GeoCoordinates(40.763573707276784, -73.94571562970638), Duration.ofMillis(4000)), // Roosevelt Bridge - new LocationKeyframeModel(new GeoCoordinates(40.773052036400294, -73.94027981305442), Duration.ofMillis(3000)), // Roosevelt Lighthouse - new LocationKeyframeModel(new GeoCoordinates(40.78270548734745, -73.92189566092568), Duration.ofMillis(3000)), // Hell gate Bridge - new LocationKeyframeModel(new GeoCoordinates(40.78406704306872, -73.91746017917936), Duration.ofMillis(2000)), // Ralph Park - new LocationKeyframeModel(new GeoCoordinates(40.768075472169045, -73.97446921306035), Duration.ofMillis(2000)), // Wollman Rink - new LocationKeyframeModel(new GeoCoordinates(40.78255966255712, -73.9586425508515), Duration.ofMillis(3000)) // Solomon Museum - ); - - return locationList; - } - - private List createOrientationsForTripToNYC() { - List orientationList = new ArrayList<>(); + List geoCoordinatesKeyframes = createGeoCoordinatesKeyframes(); + List scalarKeyframes = createScalarKeyframes(); + List geoOrientationKeyframes = createGeoOrientationKeyframes(); - Collections.addAll( - orientationList, - new OrientationKeyframeModel(new GeoOrientation(30, 60), Duration.ofMillis(0)), - new OrientationKeyframeModel(new GeoOrientation(-40, 80), Duration.ofMillis(6000)), - new OrientationKeyframeModel(new GeoOrientation(30, 70), Duration.ofMillis(6000)), - new OrientationKeyframeModel(new GeoOrientation(70, 30), Duration.ofMillis(4000)), - new OrientationKeyframeModel(new GeoOrientation(-30, 70), Duration.ofMillis(5000)), - new OrientationKeyframeModel(new GeoOrientation(30, 70), Duration.ofMillis(5000)), - new OrientationKeyframeModel(new GeoOrientation(40, 70), Duration.ofMillis(5000)), - new OrientationKeyframeModel(new GeoOrientation(80, 40), Duration.ofMillis(5000)), - new OrientationKeyframeModel(new GeoOrientation(30, 70), Duration.ofMillis(5000)) - ); - - return orientationList; - } + try { + geoCoordinatesMapCameraKeyframeTrack = MapCameraKeyframeTrack.lookAtTarget(geoCoordinatesKeyframes, EasingFunction.LINEAR, KeyframeInterpolationMode.LINEAR); + scalarMapCameraKeyframeTrack = MapCameraKeyframeTrack.lookAtDistance(scalarKeyframes, EasingFunction.LINEAR, KeyframeInterpolationMode.LINEAR); + geoOrientationMapCameraKeyframeTrack = MapCameraKeyframeTrack.lookAtOrientation(geoOrientationKeyframes, EasingFunction.LINEAR, KeyframeInterpolationMode.LINEAR); + } catch (MapCameraKeyframeTrack.InstantiationException e) { + // Throws an error if keyframes are empty or the duration of keyframes is invalid. + Log.e(TAG, e.toString()); + return null; + } - private List createScalarsForTripToNYC() { - List scalarList = new ArrayList<>(); + // Add different kinds of animation tracks that can be played back simultaneously. + // Each track can have a different total duration. + // The animation completes, when the longest track has been competed. + List mapCameraKeyframeTracks = new ArrayList<>(); - scalarList.add(new ScalarKeyframeModel(80000000.0, Duration.ofMillis(0))); - scalarList.add(new ScalarKeyframeModel(8000000.0, Duration.ofMillis(2000))); - scalarList.add(new ScalarKeyframeModel(8000.0, Duration.ofMillis(2000))); - scalarList.add(new ScalarKeyframeModel(1000.0, Duration.ofMillis(2000))); - scalarList.add(new ScalarKeyframeModel(500.0, Duration.ofMillis(3000))); + // This changes the camera's location over time. + mapCameraKeyframeTracks.add(geoCoordinatesMapCameraKeyframeTrack); + // This changes the camera's distance (= scalar) to earth over time. + mapCameraKeyframeTracks.add(scalarMapCameraKeyframeTrack); + // This changes the camera's orientation over time. + mapCameraKeyframeTracks.add(geoOrientationMapCameraKeyframeTrack); - return scalarList; + return mapCameraKeyframeTracks; } - private List createTripToNYCAnimation() { - // A list of location key frames for moving the map camera from one geo coordinate to another. - List locationKeyframesList = new ArrayList<>(); - List locationList = createLocationsForTripToNYC(); - - for (LocationKeyframeModel locationKeyframeModel: locationList) { - locationKeyframesList.add(new GeoCoordinatesKeyframe(locationKeyframeModel.geoCoordinates , locationKeyframeModel.duration)); - } - - // A list of geo orientation keyframes for changing the map camera orientation. - List orientationKeyframeList = new ArrayList<>(); - List orientationList = createOrientationsForTripToNYC(); + private List createGeoCoordinatesKeyframes() { + List geoCoordinatesKeyframes = new ArrayList<>(); - for (OrientationKeyframeModel orientationKeyframeModel: orientationList) { - orientationKeyframeList.add(new GeoOrientationKeyframe(orientationKeyframeModel.geoOrientation , orientationKeyframeModel.duration)); - } + // The duration indicates the time it takes to reach the GeoCoordinates of the keyframe. + Collections.addAll( + geoCoordinatesKeyframes, + new GeoCoordinatesKeyframe(new GeoCoordinates(40.685869754854544, -74.02550202768754), Duration.ofMillis(0)), // Statue of Liberty + new GeoCoordinatesKeyframe(new GeoCoordinates(40.69051652745291, -74.04455943649657), Duration.ofMillis(5000)), // Statue of Liberty + new GeoCoordinatesKeyframe(new GeoCoordinates(40.69051652745291, -74.04455943649657), Duration.ofMillis(7000)), // Statue of Liberty + new GeoCoordinatesKeyframe(new GeoCoordinates(40.69051652745291, -74.04455943649657), Duration.ofMillis(9000)), // Statue of Liberty + new GeoCoordinatesKeyframe(new GeoCoordinates(40.690266839135, -74.01237515471776), Duration.ofMillis(5000)), // Governor Island + new GeoCoordinatesKeyframe(new GeoCoordinates(40.7116777285189, -74.01248494562448), Duration.ofMillis(6000)), // World Trade Center + new GeoCoordinatesKeyframe(new GeoCoordinates(40.71083291395444, -74.01226399217569), Duration.ofMillis(6000)), // World Trade Center + new GeoCoordinatesKeyframe(new GeoCoordinates(40.719259512385506, -74.01171007254635), Duration.ofMillis(5000)), // Manhattan College + new GeoCoordinatesKeyframe(new GeoCoordinates(40.73603959180013, -73.98968489844603), Duration.ofMillis(6000)), // Union Square + new GeoCoordinatesKeyframe(new GeoCoordinates(40.741732824650214, -73.98825255774022), Duration.ofMillis(5000)), // Flatiron + new GeoCoordinatesKeyframe(new GeoCoordinates(40.74870637098952, -73.98515306630678), Duration.ofMillis(6000)), // Empire State Building + new GeoCoordinatesKeyframe(new GeoCoordinates(40.742693509776856, -73.95937093336781), Duration.ofMillis(3000)), // Queens Midtown + new GeoCoordinatesKeyframe(new GeoCoordinates(40.75065611103842, -73.96053139022635), Duration.ofMillis(4000)), // Roosevelt Island + new GeoCoordinatesKeyframe(new GeoCoordinates(40.756823163883794, -73.95461519921352), Duration.ofMillis(4000)), // Queens Bridge + new GeoCoordinatesKeyframe(new GeoCoordinates(40.763573707276784, -73.94571562970638), Duration.ofMillis(4000)), // Roosevelt Bridge + new GeoCoordinatesKeyframe(new GeoCoordinates(40.773052036400294, -73.94027981305442), Duration.ofMillis(3000)), // Roosevelt Lighthouse + new GeoCoordinatesKeyframe(new GeoCoordinates(40.78270548734745, -73.92189566092568), Duration.ofMillis(3000)), // Hell gate Bridge + new GeoCoordinatesKeyframe(new GeoCoordinates(40.78406704306872, -73.91746017917936), Duration.ofMillis(2000)), // Ralph Park + new GeoCoordinatesKeyframe(new GeoCoordinates(40.768075472169045, -73.97446921306035), Duration.ofMillis(2000)), // Wollman Rink + new GeoCoordinatesKeyframe(new GeoCoordinates(40.78255966255712, -73.9586425508515), Duration.ofMillis(3000))); // Solomon Museum + + return geoCoordinatesKeyframes; + } - // A list of scalar key frames for changing the map camera distance from the earth. + private List createScalarKeyframes() { List scalarKeyframesList = new ArrayList<>(); - List scalarList = createScalarsForTripToNYC(); - for (ScalarKeyframeModel scalarKeyframeModel: scalarList) { - scalarKeyframesList.add(new ScalarKeyframe(scalarKeyframeModel.scalar, scalarKeyframeModel.duration)); - } - - try { - // Creating a track to add different kinds of animations to the MapCameraKeyframeTrack. - tracks = new ArrayList<>(); - tracks.add(MapCameraKeyframeTrack.lookAtDistance(scalarKeyframesList, EasingFunction.LINEAR, KeyframeInterpolationMode.LINEAR)); - tracks.add(MapCameraKeyframeTrack.lookAtTarget(locationKeyframesList, EasingFunction.LINEAR, KeyframeInterpolationMode.LINEAR)); - tracks.add(MapCameraKeyframeTrack.lookAtOrientation(orientationKeyframeList, EasingFunction.LINEAR, KeyframeInterpolationMode.LINEAR)); - } catch (MapCameraKeyframeTrack.InstantiationException e) { - // Throws an error if keyframes is empty or duration of keyframes are invalid. - Log.e("KeyframeTrackTag", e.toString()); - } - - return tracks; + // The duration indicates the time it takes to reach the scalar (= camera distance in meters) of the keyframe. + Collections.addAll( + scalarKeyframesList, + new ScalarKeyframe(80000000.0, Duration.ofMillis(0)), + new ScalarKeyframe(8000000.0, Duration.ofMillis(2000)), + new ScalarKeyframe(8000.0, Duration.ofMillis(2000)), + new ScalarKeyframe(1000.0, Duration.ofMillis(2000)), + new ScalarKeyframe(500.0, Duration.ofMillis(3000))); + + return scalarKeyframesList; } - private void startTripToNYCAnimation(List tracks) { - try { - mapView.getCamera().startAnimation(MapCameraAnimationFactory.createAnimation(tracks)); - } catch (MapCameraAnimation.InstantiationException e) { - Log.e("KeyframeAnimationTag", e.error.name()); - } + private List createGeoOrientationKeyframes() { + List geoOrientationKeyframeList = new ArrayList<>(); + + // The duration indicates the time it takes to achieve the GeoOrientation of the keyframe. + Collections.addAll( + geoOrientationKeyframeList, + new GeoOrientationKeyframe(new GeoOrientation(30, 60) , Duration.ofMillis(0)), + new GeoOrientationKeyframe(new GeoOrientation(-40, 80), Duration.ofMillis(6000)), + new GeoOrientationKeyframe(new GeoOrientation(30, 70), Duration.ofMillis(6000)), + new GeoOrientationKeyframe(new GeoOrientation(70, 30), Duration.ofMillis(4000)), + new GeoOrientationKeyframe(new GeoOrientation(-30, 70), Duration.ofMillis(5000)), + new GeoOrientationKeyframe(new GeoOrientation(30, 70), Duration.ofMillis(5000)), + new GeoOrientationKeyframe(new GeoOrientation(40, 70), Duration.ofMillis(5000)), + new GeoOrientationKeyframe(new GeoOrientation(80, 40), Duration.ofMillis(5000)), + new GeoOrientationKeyframe(new GeoOrientation(30, 70), Duration.ofMillis(5000))); + + return geoOrientationKeyframeList; } } diff --git a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/MainActivity.java b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/MainActivity.java index e0f545be..bb94629d 100644 --- a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/MainActivity.java +++ b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/MainActivity.java @@ -19,7 +19,6 @@ package com.here.camerakeyframetracks; -import android.annotation.SuppressLint; import android.os.Bundle; import android.util.Log; import android.view.Menu; @@ -30,8 +29,6 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; -import com.here.camerakeyframetracks.helper.PermissionsRequestor; -import com.here.camerakeyframetracks.helper.RouteCalculator; import com.here.sdk.core.GeoCoordinates; import com.here.sdk.core.engine.SDKNativeEngine; import com.here.sdk.mapview.MapError; @@ -76,9 +73,9 @@ public void permissionsDenied() { }); } - @SuppressLint("MissingSuperCall") @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); permissionsRequestor.onRequestPermissionsResult(requestCode, grantResults); } @@ -107,18 +104,13 @@ public boolean onCreateOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { - if (RouteCalculator.testRoute == null) { - Log.e("MainActivity", "Error: No route for testing ..."); - return false; - } - switch (item.getItemId()) { case R.id.stopToRouteAnimation: routeAnimationExample.stopRouteAnimation(); return true; case R.id.startToRouteAnimation: // An animation that moves the camera to the route without keyframe tracks. - routeAnimationExample.animateToRoute(RouteCalculator.testRoute); + routeAnimationExample.animateToRoute(); return true; case R.id.startNYCAnimation: // A camera animation through New York. @@ -134,25 +126,27 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/helper/PermissionsRequestor.java b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/PermissionsRequestor.java similarity index 98% rename from examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/helper/PermissionsRequestor.java rename to examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/PermissionsRequestor.java index 429d64df..027dd17b 100644 --- a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/helper/PermissionsRequestor.java +++ b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/PermissionsRequestor.java @@ -17,7 +17,7 @@ * License-Filename: LICENSE */ -package com.here.camerakeyframetracks.helper; +package com.here.camerakeyframetracks; import android.Manifest; import android.app.Activity; diff --git a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteAnimationExample.java b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteAnimationExample.java index d58d1073..a200f110 100644 --- a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteAnimationExample.java +++ b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteAnimationExample.java @@ -21,7 +21,6 @@ import android.util.Log; -import com.here.camerakeyframetracks.helper.RouteCalculator; import com.here.sdk.animation.EasingFunction; import com.here.sdk.core.GeoOrientationUpdate; import com.here.sdk.core.Point2D; @@ -52,16 +51,25 @@ public void stopRouteAnimation() { mapView.getCamera().cancelAnimations(); } - public void animateToRoute(Route route) { - // Untilt and unrotate the map. + public void animateToRoute() { + if (RouteCalculator.testRoute == null) { + Log.e("RouteAnimationExample", "Error: No route for testing ..."); + return; + } + + animateToRoute(RouteCalculator.testRoute); + } + + private void animateToRoute(Route route) { + // The animation should result in an untilted and unrotated map. double bearing = 0; double tilt = 0; - // We want to show the route fitting in the map view without any additional padding. - Point2D origin = new Point2D(0, 0); - Size2D sizeInPixels = new Size2D(mapView.getWidth(), mapView.getHeight()); + // We want to show the route fitting in the map view with an additional padding of 50 pixels + Point2D origin = new Point2D(50, 50); + Size2D sizeInPixels = new Size2D(mapView.getWidth() - 100, mapView.getHeight() - 100); Rectangle2D mapViewport = new Rectangle2D(origin, sizeInPixels); - // Animate to route. + // Animate to the route within a duration of 3 seconds. MapCameraUpdate update = MapCameraUpdateFactory.lookAt( route.getBoundingBox(), new GeoOrientationUpdate(bearing, tilt), diff --git a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/helper/RouteCalculator.java b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteCalculator.java similarity index 80% rename from examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/helper/RouteCalculator.java rename to examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteCalculator.java index ccbb9748..5b01d70b 100644 --- a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/helper/RouteCalculator.java +++ b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteCalculator.java @@ -17,7 +17,7 @@ * License-Filename: LICENSE */ -package com.here.camerakeyframetracks.helper; +package com.here.camerakeyframetracks; import android.util.Log; @@ -29,11 +29,9 @@ import com.here.sdk.core.errors.InstantiationErrorException; import com.here.sdk.mapview.MapPolyline; import com.here.sdk.mapview.MapView; -import com.here.sdk.routing.CalculateRouteCallback; import com.here.sdk.routing.CarOptions; import com.here.sdk.routing.Route; import com.here.sdk.routing.RoutingEngine; -import com.here.sdk.routing.RoutingError; import com.here.sdk.routing.Waypoint; import java.util.ArrayList; @@ -60,19 +58,16 @@ public RouteCalculator(MapView mapView) { } public void createRoute() { - // A random test route. + // A fixed test route. Waypoint startWaypoint = new Waypoint(new GeoCoordinates(40.7133, -74.0112)); Waypoint destinationWaypoint = new Waypoint(new GeoCoordinates(40.7203, -74.3122)); List waypoints = new ArrayList<>(Arrays.asList(startWaypoint, destinationWaypoint)); - routingEngine.calculateRoute(waypoints, new CarOptions(), new CalculateRouteCallback() { - @Override - public void onRouteCalculated(@Nullable RoutingError routingError, @Nullable List routes) { - if (routingError == null) { - testRoute = routes.get(0); - showRouteOnMap(testRoute); - } else { - Log.e("RouteCalculator", "RoutingError: " + routingError.name()); - } + routingEngine.calculateRoute(waypoints, new CarOptions(), (routingError, routes) -> { + if (routingError == null) { + testRoute = routes.get(0); + showRouteOnMap(testRoute); + } else { + Log.e("RouteCalculator", "RoutingError: " + routingError.name()); } }); } diff --git a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/LocationKeyframeModel.java b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/LocationKeyframeModel.java deleted file mode 100644 index 9b013ac3..00000000 --- a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/LocationKeyframeModel.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.here.camerakeyframetracks.models; - -import com.here.sdk.core.GeoCoordinates; -import com.here.time.Duration; - -// A data class meant to be used for the creation of GeoCoordinatesKeyframe instances that hold -// a GeoCoordinates object and the animation duration to reach these coordinates. -public class LocationKeyframeModel { - public GeoCoordinates geoCoordinates; - public Duration duration; - - public LocationKeyframeModel(GeoCoordinates geoCoordinates, Duration duration) { - this.geoCoordinates = geoCoordinates; - this.duration = duration; - } -} diff --git a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/OrientationKeyframeModel.java b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/OrientationKeyframeModel.java deleted file mode 100644 index 0b6fe6c0..00000000 --- a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/OrientationKeyframeModel.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.here.camerakeyframetracks.models; - -import com.here.sdk.core.GeoOrientation; -import com.here.time.Duration; - -// A data class meant to be used for the creation of GeoOrientationKeyframe instances that hold -// a GeoOrientation and the animation duration to reach the GeoOrientation. -public class OrientationKeyframeModel { - public GeoOrientation geoOrientation; - public Duration duration; - - public OrientationKeyframeModel(GeoOrientation geoOrientation, Duration duration) { - this.geoOrientation = geoOrientation; - this.duration = duration; - } -} diff --git a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/ScalarKeyframeModel.java b/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/ScalarKeyframeModel.java deleted file mode 100644 index b41230d1..00000000 --- a/examples/latest/explore/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/ScalarKeyframeModel.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.here.camerakeyframetracks.models; - -import com.here.time.Duration; - -// A data class meant to be used for the creation of ScalarKeyframe instances that hold -// a distance in meters and the animation duration to reach this distance. -public class ScalarKeyframeModel { - public Double scalar; - public Duration duration; - - public ScalarKeyframeModel(Double scalar, Duration duration) { - this.scalar = scalar; - this.duration = duration; - } -} diff --git a/examples/latest/explore/android/CustomMapStylesExplore/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/CustomMapStylesExplore/app/src/main/AndroidManifest.xml index 6f2e50e5..bb8dff62 100644 --- a/examples/latest/explore/android/CustomMapStylesExplore/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/CustomMapStylesExplore/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/CustomMapStylesExplore/app/src/main/java/com/here/sdk/custommapstyles/MainActivity.java b/examples/latest/explore/android/CustomMapStylesExplore/app/src/main/java/com/here/sdk/custommapstyles/MainActivity.java index 578ec00d..753faf29 100644 --- a/examples/latest/explore/android/CustomMapStylesExplore/app/src/main/java/com/here/sdk/custommapstyles/MainActivity.java +++ b/examples/latest/explore/android/CustomMapStylesExplore/app/src/main/java/com/here/sdk/custommapstyles/MainActivity.java @@ -92,25 +92,27 @@ public void unloadButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/CustomRasterLayers/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/CustomRasterLayers/app/src/main/AndroidManifest.xml index 27e66755..b8e25e23 100644 --- a/examples/latest/explore/android/CustomRasterLayers/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/CustomRasterLayers/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/CustomRasterLayersExample.java b/examples/latest/explore/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/CustomRasterLayersExample.java index e096738b..1a62d084 100644 --- a/examples/latest/explore/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/CustomRasterLayersExample.java +++ b/examples/latest/explore/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/CustomRasterLayersExample.java @@ -19,14 +19,21 @@ package com.here.sdk.customrasterlayers; + import android.content.Context; + + import com.here.sdk.core.Anchor2D; import com.here.sdk.core.GeoCoordinates; + import com.here.sdk.core.Metadata; import com.here.sdk.mapview.MapCamera; import com.here.sdk.mapview.MapContentType; + import com.here.sdk.mapview.MapImage; + import com.here.sdk.mapview.MapImageFactory; import com.here.sdk.mapview.MapLayer; import com.here.sdk.mapview.MapLayerBuilder; import com.here.sdk.mapview.MapLayerPriority; import com.here.sdk.mapview.MapLayerPriorityBuilder; import com.here.sdk.mapview.MapLayerVisibilityRange; + import com.here.sdk.mapview.MapMarker; import com.here.sdk.mapview.MapMeasure; import com.here.sdk.mapview.MapView; import com.here.sdk.mapview.datasource.RasterDataSource; @@ -43,9 +50,11 @@ public class CustomRasterLayersExample { private MapView mapView; private MapLayer rasterMapLayerTonerStyle; private RasterDataSource rasterDataSourceTonerStyle; + private Context context; - public void onMapSceneLoaded(MapView mapView) { + public void onMapSceneLoaded(MapView mapView, Context context) { this.mapView = mapView; + this.context = context; MapCamera camera = mapView.getCamera(); MapMeasure mapMeasureZoom = new MapMeasure(MapMeasure.Kind.DISTANCE, DEFAULT_DISTANCE_TO_EARTH_IN_METERS); @@ -57,6 +66,9 @@ public void onMapSceneLoaded(MapView mapView) { // We want to start with the default map style. rasterMapLayerTonerStyle.setEnabled(false); + + // Add a POI marker + addPOIMapMarker(new GeoCoordinates(52.530932, 13.384915)); } public void enableButtonClicked() { @@ -81,6 +93,9 @@ private RasterDataSource createRasterDataSource(String dataSourceName) { TilingScheme.QUAD_TREE_MERCATOR, storageLevels); + // If you want to add transparent layers then set this to true. + rasterProviderConfig.hasAlphaChannel = false; + // Raster tiles are stored in a separate cache on the device. String path = "cache/raster/toner"; long maxDiskSizeInBytes = 1024 * 1024 * 32; @@ -92,8 +107,8 @@ private RasterDataSource createRasterDataSource(String dataSourceName) { } private MapLayer createMapLayer(String dataSourceName) { - // The layer should be rendered on top of other layers. - MapLayerPriority priority = new MapLayerPriorityBuilder().renderedLast().build(); + // The layer should be rendered on top of other layers except the cartography layer consisting of the embedded Carto POI markers. + MapLayerPriority priority = new MapLayerPriorityBuilder().renderedLast().renderedAfterLayer("ocm_cartography").build(); // And it should be visible for all zoom levels. MapLayerVisibilityRange range = new MapLayerVisibilityRange(0, 22 + 1); @@ -116,4 +131,15 @@ public void onDestroy() { rasterMapLayerTonerStyle.destroy(); rasterDataSourceTonerStyle.destroy(); } + + private void addPOIMapMarker(GeoCoordinates geoCoordinates) { + MapImage mapImage = MapImageFactory.fromResource(context.getResources(), R.drawable.poi); + + // The bottom, middle position should point to the location. + // By default, the anchor point is set to 0.5, 0.5. + Anchor2D anchor2D = new Anchor2D(0.5F, 1); + MapMarker mapMarker = new MapMarker(geoCoordinates, mapImage, anchor2D); + + mapView.getMapScene().addMapMarker(mapMarker); + } } diff --git a/examples/latest/explore/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/MainActivity.java b/examples/latest/explore/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/MainActivity.java index e0ecdcde..85b844da 100644 --- a/examples/latest/explore/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/MainActivity.java +++ b/examples/latest/explore/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/MainActivity.java @@ -74,7 +74,7 @@ private void loadMapScene() { public void onLoadScene(@Nullable MapError mapError) { if (mapError == null) { customRasterLayersExample = new CustomRasterLayersExample(); - customRasterLayersExample.onMapSceneLoaded(mapView); + customRasterLayersExample.onMapSceneLoaded(mapView, MainActivity.this); } else { Log.d(TAG, "onLoadScene failed: " + mapError.toString()); } @@ -92,28 +92,29 @@ public void disableButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); - customRasterLayersExample.onDestroy(); mapView.onDestroy(); - + // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/CustomRasterLayers/app/src/main/res/drawable/poi.png b/examples/latest/explore/android/CustomRasterLayers/app/src/main/res/drawable/poi.png new file mode 100644 index 00000000..808c67e5 Binary files /dev/null and b/examples/latest/explore/android/CustomRasterLayers/app/src/main/res/drawable/poi.png differ diff --git a/examples/latest/explore/android/EVRouting/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/EVRouting/app/src/main/AndroidManifest.xml index 19d2dc16..a12abaf6 100644 --- a/examples/latest/explore/android/EVRouting/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/EVRouting/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/EVRouting/app/src/main/java/com/here/evrouting/EVRoutingExample.java b/examples/latest/explore/android/EVRouting/app/src/main/java/com/here/evrouting/EVRoutingExample.java index 6d4271ea..838c7bf9 100644 --- a/examples/latest/explore/android/EVRouting/app/src/main/java/com/here/evrouting/EVRoutingExample.java +++ b/examples/latest/explore/android/EVRouting/app/src/main/java/com/here/evrouting/EVRoutingExample.java @@ -40,6 +40,7 @@ import com.here.sdk.mapview.MapPolygon; import com.here.sdk.mapview.MapPolyline; import com.here.sdk.mapview.MapView; +import com.here.sdk.routing.AvoidanceOptions; import com.here.sdk.routing.CalculateIsolineCallback; import com.here.sdk.routing.CalculateRouteCallback; import com.here.sdk.routing.ChargingConnectorType; @@ -152,12 +153,18 @@ private EVCarOptions getEVCarOptions() { put(90, 0.238); }}; - // Ensure that the vehicle does not run out of energy along the way and charging stations are added as additional waypoints. + // Must be 0 for isoline calculation. + evCarOptions.routeOptions.alternatives = 0; + + // Ensure that the vehicle does not run out of energy along the way + // and charging stations are added as additional waypoints. evCarOptions.ensureReachability = true; - // The below options are required when setting the ensureReachability option to true. + // The below options are required when setting the ensureReachability option to true + // (AvoidanceOptions need to be empty). + evCarOptions.avoidanceOptions = new AvoidanceOptions(); + evCarOptions.routeOptions.speedCapInMetersPerSecond = null; evCarOptions.routeOptions.optimizationMode = OptimizationMode.FASTEST; - evCarOptions.routeOptions.alternatives = 0; evCarOptions.batterySpecifications.connectorTypes = new ArrayList<>(Arrays.asList(ChargingConnectorType.TESLA, ChargingConnectorType.IEC_62196_TYPE_1_COMBO, ChargingConnectorType.IEC_62196_TYPE_2_COMBO)); diff --git a/examples/latest/explore/android/EVRouting/app/src/main/java/com/here/evrouting/MainActivity.java b/examples/latest/explore/android/EVRouting/app/src/main/java/com/here/evrouting/MainActivity.java index 54f96a6e..6cd902ea 100644 --- a/examples/latest/explore/android/EVRouting/app/src/main/java/com/here/evrouting/MainActivity.java +++ b/examples/latest/explore/android/EVRouting/app/src/main/java/com/here/evrouting/MainActivity.java @@ -100,25 +100,27 @@ public void clearMapButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/Gestures/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/Gestures/app/src/main/AndroidManifest.xml index 4d6a9206..faf27f8f 100644 --- a/examples/latest/explore/android/Gestures/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/Gestures/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/Gestures/app/src/main/java/com/here/gestures/MainActivity.java b/examples/latest/explore/android/Gestures/app/src/main/java/com/here/gestures/MainActivity.java index 2c241354..6a756586 100644 --- a/examples/latest/explore/android/Gestures/app/src/main/java/com/here/gestures/MainActivity.java +++ b/examples/latest/explore/android/Gestures/app/src/main/java/com/here/gestures/MainActivity.java @@ -87,25 +87,27 @@ public void onLoadScene(@Nullable MapError mapError) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/HelloMap/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/HelloMap/app/src/main/AndroidManifest.xml index af30eacc..3f669d9c 100644 --- a/examples/latest/explore/android/HelloMap/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/HelloMap/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/HelloMap/app/src/main/java/com/here/hellomap/MainActivity.java b/examples/latest/explore/android/HelloMap/app/src/main/java/com/here/hellomap/MainActivity.java index f7f98eaf..aca22909 100644 --- a/examples/latest/explore/android/HelloMap/app/src/main/java/com/here/hellomap/MainActivity.java +++ b/examples/latest/explore/android/HelloMap/app/src/main/java/com/here/hellomap/MainActivity.java @@ -105,25 +105,27 @@ public void onLoadScene(@Nullable MapError mapError) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/HelloMapAndroidAuto/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/HelloMapAndroidAuto/app/src/main/AndroidManifest.xml index beb69b0a..ab7a4178 100644 --- a/examples/latest/explore/android/HelloMapAndroidAuto/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/HelloMapAndroidAuto/app/src/main/AndroidManifest.xml @@ -23,7 +23,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/HelloMapAndroidAuto/app/src/main/java/com/here/hellomapandroidauto/MainActivity.java b/examples/latest/explore/android/HelloMapAndroidAuto/app/src/main/java/com/here/hellomapandroidauto/MainActivity.java index 39601a84..2c53b017 100644 --- a/examples/latest/explore/android/HelloMapAndroidAuto/app/src/main/java/com/here/hellomapandroidauto/MainActivity.java +++ b/examples/latest/explore/android/HelloMapAndroidAuto/app/src/main/java/com/here/hellomapandroidauto/MainActivity.java @@ -104,25 +104,27 @@ public void onLoadScene(@Nullable MapError mapError) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/HelloMapKotlin/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/HelloMapKotlin/app/src/main/AndroidManifest.xml index af30eacc..3f669d9c 100644 --- a/examples/latest/explore/android/HelloMapKotlin/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/HelloMapKotlin/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/HelloMapKotlin/app/src/main/java/com/here/hellomap/MainActivity.kt b/examples/latest/explore/android/HelloMapKotlin/app/src/main/java/com/here/hellomap/MainActivity.kt index f0e2281f..8d8e16de 100644 --- a/examples/latest/explore/android/HelloMapKotlin/app/src/main/java/com/here/hellomap/MainActivity.kt +++ b/examples/latest/explore/android/HelloMapKotlin/app/src/main/java/com/here/hellomap/MainActivity.kt @@ -81,24 +81,28 @@ class MainActivity : AppCompatActivity() { } override fun onPause() { - super.onPause() mapView?.onPause() + super.onPause() } override fun onResume() { - super.onResume() mapView?.onResume() + super.onResume() } override fun onDestroy() { - super.onDestroy() mapView?.onDestroy() // Free HERE SDK resources before the application shuts down. SDKNativeEngine.getSharedInstance()?.dispose() + + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null) + + super.onDestroy() } companion object { private val TAG = MainActivity::class.java.simpleName } -} \ No newline at end of file +} diff --git a/examples/latest/explore/android/MapItems/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/MapItems/app/src/main/AndroidManifest.xml index 726da8f2..e0c806a2 100644 --- a/examples/latest/explore/android/MapItems/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/MapItems/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/MapItems/app/src/main/java/com/here/mapitems/MainActivity.java b/examples/latest/explore/android/MapItems/app/src/main/java/com/here/mapitems/MainActivity.java index 730db59a..c5d38175 100644 --- a/examples/latest/explore/android/MapItems/app/src/main/java/com/here/mapitems/MainActivity.java +++ b/examples/latest/explore/android/MapItems/app/src/main/java/com/here/mapitems/MainActivity.java @@ -103,26 +103,28 @@ public void onLoadScene(@Nullable MapError mapError) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } @Override @@ -171,8 +173,11 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { case R.id.active_inactive_menu_item: mapItemsExample.toggleActiveStateForLocationIndicator(); return true; + case R.id.flat_menu_item_image: + mapItemsExample.showFlatMapMarker(); + return true; case R.id.flat_menu_item: - mapItemsExample.showFlatMarker(); + mapItemsExample.show2DTexture(); return true; case R.id.obj_3D_menu_item: mapItemsExample.showMapMarker3D(); diff --git a/examples/latest/explore/android/MapItems/app/src/main/java/com/here/mapitems/MapItemsExample.java b/examples/latest/explore/android/MapItems/app/src/main/java/com/here/mapitems/MapItemsExample.java index caa1451a..c220bcb3 100644 --- a/examples/latest/explore/android/MapItems/app/src/main/java/com/here/mapitems/MapItemsExample.java +++ b/examples/latest/explore/android/MapItems/app/src/main/java/com/here/mapitems/MapItemsExample.java @@ -45,6 +45,7 @@ import com.here.sdk.mapview.MapView; import com.here.sdk.mapview.MapViewBase; import com.here.sdk.mapview.PickMapItemsResult; +import com.here.sdk.mapview.RenderSize; import com.here.time.Duration; import java.io.IOException; @@ -134,14 +135,14 @@ public void showLocationIndicatorNavigation() { addLocationIndicator(geoCoordinates, LocationIndicator.IndicatorStyle.NAVIGATION); } - public void showFlatMarker() { + public void show2DTexture() { // Tilt the map for a better 3D effect. tiltMap(); GeoCoordinates geoCoordinates = createRandomGeoCoordinatesAroundMapCenter(); // Adds a flat POI marker that rotates and tilts together with the map. - addFlatMarker3D(geoCoordinates); + add2DTexture(geoCoordinates); // A centered 2D map marker to indicate the exact location. // Note that 3D map markers are always drawn on top of 2D map markers. @@ -159,6 +160,19 @@ public void showMapMarker3D() { addMapMarker3D(geoCoordinates); } + public void showFlatMapMarker() { + // Tilt the map for a better 3D effect. + tiltMap(); + + GeoCoordinates geoCoordinates = createRandomGeoCoordinatesAroundMapCenter(); + + // It's origin is centered on the location. + addFlatMarker(geoCoordinates); + + // A centered 2D map marker to indicate the exact location. + addCircleMapMarker(geoCoordinates); + } + public void clearMap() { mapView.getMapScene().removeMapMarkers(mapMarkerList); mapMarkerList.clear(); @@ -242,7 +256,7 @@ public void toggleActiveStateForLocationIndicator() { } } - private void addFlatMarker3D(GeoCoordinates geoCoordinates) { + private void add2DTexture(GeoCoordinates geoCoordinates) { // Place the files in the "assets" directory. // Full path example: app/src/main/assets/plane.obj // Adjust file name and path as appropriate for your project. @@ -263,6 +277,20 @@ private void addFlatMarker3D(GeoCoordinates geoCoordinates) { mapMarker3DList.add(mapMarker3D); } + private void addFlatMarker(GeoCoordinates geoCoordinates) { + MapImage mapImage = MapImageFactory.fromResource(context.getResources(), R.drawable.poi); + + // The default scale factor of the map marker is 1.0. For a scale of 2, the map marker becomes 2x larger. + // For a scale of 0.5, the map marker shrinks to half of its original size. + double scaleFactor = 0.5; + + // With DENSITY_INDEPENDENT_PIXELS the map marker will have a constant size on the screen regardless if the map is zoomed in or out. + MapMarker3D mapMarker3D = new MapMarker3D(geoCoordinates, mapImage, scaleFactor, RenderSize.Unit.DENSITY_INDEPENDENT_PIXELS); + + mapView.getMapScene().addMapMarker3d(mapMarker3D); + mapMarker3DList.add(mapMarker3D); + } + private void addMapMarker3D(GeoCoordinates geoCoordinates) { // Place the files in the "assets" directory. // Full path example: app/src/main/assets/obstacle.obj diff --git a/examples/latest/explore/android/MapItems/app/src/main/res/menu/map_option_menu.xml b/examples/latest/explore/android/MapItems/app/src/main/res/menu/map_option_menu.xml index 274d223e..aa8d0a63 100644 --- a/examples/latest/explore/android/MapItems/app/src/main/res/menu/map_option_menu.xml +++ b/examples/latest/explore/android/MapItems/app/src/main/res/menu/map_option_menu.xml @@ -35,8 +35,10 @@ android:title="Location (NAV)"/> + + android:title="2D Texture"/> + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/PublicTransit/app/src/main/java/com/here/routing/MainActivity.java b/examples/latest/explore/android/PublicTransit/app/src/main/java/com/here/routing/MainActivity.java index f9f2a79b..a8ee4635 100644 --- a/examples/latest/explore/android/PublicTransit/app/src/main/java/com/here/routing/MainActivity.java +++ b/examples/latest/explore/android/PublicTransit/app/src/main/java/com/here/routing/MainActivity.java @@ -96,25 +96,27 @@ public void clearMapButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/Routing/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/Routing/app/src/main/AndroidManifest.xml index 20c034f6..c5eef4e1 100644 --- a/examples/latest/explore/android/Routing/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/Routing/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/Routing/app/src/main/java/com/here/routing/MainActivity.java b/examples/latest/explore/android/Routing/app/src/main/java/com/here/routing/MainActivity.java index 682c46e5..036d5ec4 100644 --- a/examples/latest/explore/android/Routing/app/src/main/java/com/here/routing/MainActivity.java +++ b/examples/latest/explore/android/Routing/app/src/main/java/com/here/routing/MainActivity.java @@ -100,25 +100,27 @@ public void clearMapButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); - } + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); + } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/Search/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/Search/app/src/main/AndroidManifest.xml index e9f683af..98221588 100644 --- a/examples/latest/explore/android/Search/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/Search/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/Search/app/src/main/java/com/here/search/MainActivity.java b/examples/latest/explore/android/Search/app/src/main/java/com/here/search/MainActivity.java index 38e3acaf..189725b9 100644 --- a/examples/latest/explore/android/Search/app/src/main/java/com/here/search/MainActivity.java +++ b/examples/latest/explore/android/Search/app/src/main/java/com/here/search/MainActivity.java @@ -100,25 +100,27 @@ public void geocodeAnAddressButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/StandAloneEngine/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/StandAloneEngine/app/src/main/AndroidManifest.xml index 19083e82..a35f4c42 100644 --- a/examples/latest/explore/android/StandAloneEngine/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/StandAloneEngine/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/StandAloneEngine/app/src/main/java/com/here/sdk/standaloneengine/MainActivity.java b/examples/latest/explore/android/StandAloneEngine/app/src/main/java/com/here/sdk/standaloneengine/MainActivity.java index d81c2ee5..0266f6d4 100644 --- a/examples/latest/explore/android/StandAloneEngine/app/src/main/java/com/here/sdk/standaloneengine/MainActivity.java +++ b/examples/latest/explore/android/StandAloneEngine/app/src/main/java/com/here/sdk/standaloneengine/MainActivity.java @@ -101,12 +101,14 @@ public void onSearchCompleted(SearchError searchError, List list) { @Override protected void onDestroy() { - super.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/Traffic/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/Traffic/app/src/main/AndroidManifest.xml index 8c679ee1..7eb8811d 100644 --- a/examples/latest/explore/android/Traffic/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/Traffic/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/Traffic/app/src/main/java/com/here/traffic/MainActivity.java b/examples/latest/explore/android/Traffic/app/src/main/java/com/here/traffic/MainActivity.java index 73ff20f6..127059c2 100644 --- a/examples/latest/explore/android/Traffic/app/src/main/java/com/here/traffic/MainActivity.java +++ b/examples/latest/explore/android/Traffic/app/src/main/java/com/here/traffic/MainActivity.java @@ -98,25 +98,27 @@ public void disableAllButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); - } + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); + } + super.onDestroy(); } } diff --git a/examples/latest/explore/android/UnitTesting/app/src/main/AndroidManifest.xml b/examples/latest/explore/android/UnitTesting/app/src/main/AndroidManifest.xml index af30eacc..3f669d9c 100644 --- a/examples/latest/explore/android/UnitTesting/app/src/main/AndroidManifest.xml +++ b/examples/latest/explore/android/UnitTesting/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/explore/android/UnitTesting/app/src/main/java/com/here/hellomap/MainActivity.java b/examples/latest/explore/android/UnitTesting/app/src/main/java/com/here/hellomap/MainActivity.java index 4fbc9f59..6187421f 100644 --- a/examples/latest/explore/android/UnitTesting/app/src/main/java/com/here/hellomap/MainActivity.java +++ b/examples/latest/explore/android/UnitTesting/app/src/main/java/com/here/hellomap/MainActivity.java @@ -98,25 +98,27 @@ public void onLoadScene(@Nullable MapError mapError) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/explore/flutter/custom_raster_layers_app/assets/poi.png b/examples/latest/explore/flutter/custom_raster_layers_app/assets/poi.png new file mode 100644 index 00000000..9ce63731 Binary files /dev/null and b/examples/latest/explore/flutter/custom_raster_layers_app/assets/poi.png differ diff --git a/examples/latest/explore/flutter/custom_raster_layers_app/lib/CustomRasterLayersExample.dart b/examples/latest/explore/flutter/custom_raster_layers_app/lib/CustomRasterLayersExample.dart index 4b7f9313..b7502eb0 100644 --- a/examples/latest/explore/flutter/custom_raster_layers_app/lib/CustomRasterLayersExample.dart +++ b/examples/latest/explore/flutter/custom_raster_layers_app/lib/CustomRasterLayersExample.dart @@ -17,6 +17,8 @@ * License-Filename: LICENSE */ +import 'dart:typed_data'; +import 'package:flutter/services.dart'; import 'package:here_sdk/core.dart'; import 'package:here_sdk/mapview.dart'; import 'package:here_sdk/mapview.datasource.dart'; @@ -25,6 +27,7 @@ class CustomRasterLayersExample { HereMapController _hereMapController; MapLayer? _rasterMapLayerTonerStyle; RasterDataSource? _rasterDataSourceTonerStyle; + MapImage? _poiMapImage; CustomRasterLayersExample(HereMapController this._hereMapController) { double distanceToEarthInMeters = 60000; @@ -37,6 +40,9 @@ class CustomRasterLayersExample { // We want to start with the default map style. _rasterMapLayerTonerStyle?.setEnabled(false); + + // Add a POI marker + _addPOIMapMarker(GeoCoordinates(52.530932, 13.384915), 1); } void enableButtonClicked() { @@ -59,6 +65,9 @@ class CustomRasterLayersExample { RasterDataSourceProviderConfiguration rasterProviderConfig = RasterDataSourceProviderConfiguration.withDefaults(templateUrl, TilingScheme.quadTreeMercator, storageLevels); + // If you want to add transparent layers then set this to true. + rasterProviderConfig.hasAlphaChannel = false; + // Raster tiles are stored in a separate cache on the device. String path = "cache/raster/toner"; int maxDiskSizeInBytes = 1024 * 1024 * 32; @@ -70,8 +79,8 @@ class CustomRasterLayersExample { } MapLayer _createMapLayer(String dataSourceName) { - // The layer should be rendered on top of other layers. - MapLayerPriority priority = MapLayerPriorityBuilder().renderedLast().build(); + // The layer should be rendered on top of other layers except the cartography layer consisting of the embedded Carto POI markers. + MapLayerPriority priority = MapLayerPriorityBuilder().renderedLast().renderedAfterLayer("ocm_cartography").build(); // And it should be visible for all zoom levels. MapLayerVisibilityRange range = MapLayerVisibilityRange(0, 22 + 1); @@ -94,4 +103,27 @@ class CustomRasterLayersExample { _rasterMapLayerTonerStyle?.destroy(); _rasterDataSourceTonerStyle?.destroy(); } + + Future _addPOIMapMarker(GeoCoordinates geoCoordinates, int drawOrder) async { + // Reuse existing MapImage for new map markers. + if (_poiMapImage == null) { + Uint8List imagePixelData = await _loadFileAsUint8List('assets/poi.png'); + _poiMapImage = MapImage.withPixelDataAndImageFormat(imagePixelData, ImageFormat.png); + } + + // By default, the anchor point is set to 0.5, 0.5 (= centered). + // Here the bottom, middle position should point to the location. + Anchor2D anchor2D = Anchor2D.withHorizontalAndVertical(0.5, 1); + + MapMarker mapMarker = MapMarker.withAnchor(geoCoordinates, _poiMapImage!, anchor2D); + mapMarker.drawOrder = drawOrder; + + _hereMapController.mapScene.addMapMarker(mapMarker); + } + + Future _loadFileAsUint8List(String assetPathToFile) async { + // The path refers to the assets directory as specified in pubspec.yaml. + ByteData fileData = await rootBundle.load(assetPathToFile); + return Uint8List.view(fileData.buffer); + } } diff --git a/examples/latest/explore/flutter/custom_raster_layers_app/pubspec.yaml b/examples/latest/explore/flutter/custom_raster_layers_app/pubspec.yaml index 86471971..73507c13 100644 --- a/examples/latest/explore/flutter/custom_raster_layers_app/pubspec.yaml +++ b/examples/latest/explore/flutter/custom_raster_layers_app/pubspec.yaml @@ -50,9 +50,8 @@ flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg + assets: + - assets/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware. diff --git a/examples/latest/explore/flutter/ev_routing_app/lib/EVRoutingExample.dart b/examples/latest/explore/flutter/ev_routing_app/lib/EVRoutingExample.dart index 4dafa4f3..6ae77a39 100644 --- a/examples/latest/explore/flutter/ev_routing_app/lib/EVRoutingExample.dart +++ b/examples/latest/explore/flutter/ev_routing_app/lib/EVRoutingExample.dart @@ -102,12 +102,18 @@ class EVRoutingExample { evCarOptions.consumptionModel.descentRecoveryInWattHoursPerMeter = 4.3; evCarOptions.consumptionModel.freeFlowSpeedTable = {0: 0.239, 27: 0.239, 60: 0.196, 90: 0.238}; - // Ensure that the vehicle does not run out of energy along the way and charging stations are added as additional waypoints. + // Must be 0 for isoline calculation. + evCarOptions.routeOptions.alternatives = 0; + + // Ensure that the vehicle does not run out of energy along the way + // and charging stations are added as additional waypoints. evCarOptions.ensureReachability = true; - // The below options are required when setting the ensureReachability option to true. + // The below options are required when setting the ensureReachability option to true + // (AvoidanceOptions need to be empty). + evCarOptions.avoidanceOptions = AvoidanceOptions.withDefaults(); + evCarOptions.routeOptions.speedCapInMetersPerSecond = null; evCarOptions.routeOptions.optimizationMode = OptimizationMode.fastest; - evCarOptions.routeOptions.alternatives = 0; evCarOptions.batterySpecifications.connectorTypes = [ ChargingConnectorType.tesla, ChargingConnectorType.iec62196Type1Combo, diff --git a/examples/latest/explore/flutter/map_items_app/lib/MapItemsExample.dart b/examples/latest/explore/flutter/map_items_app/lib/MapItemsExample.dart index 60dfe24e..300c02ec 100644 --- a/examples/latest/explore/flutter/map_items_app/lib/MapItemsExample.dart +++ b/examples/latest/explore/flutter/map_items_app/lib/MapItemsExample.dart @@ -17,6 +17,7 @@ * License-Filename: LICENSE */ +import 'dart:io'; import 'dart:math'; import 'dart:typed_data'; @@ -127,14 +128,28 @@ class MapItemsExample { _addLocationIndicator(geoCoordinates, LocationIndicatorIndicatorStyle.navigation); } - void showFlatMapMarkers() { + void showFlatMapMarker() { + // Tilt the map for a better 3D effect. + _tiltMap(); + + GeoCoordinates geoCoordinates = _createRandomGeoCoordinatesAroundMapCenter(); + + // It's origin is centered on the location. + _addFlatMarker(geoCoordinates); + + // A centered 2D map marker to indicate the exact location. + // Note that 3D map markers are always drawn on top of 2D map markers. + _addCircleMapMarker(geoCoordinates, 1); + } + + void show2DTexture() { // Tilt the map for a better 3D effect. _tiltMap(); GeoCoordinates geoCoordinates = _createRandomGeoCoordinatesAroundMapCenter(); // Adds a flat POI marker that rotates and tilts together with the map. - _addFlatMarker3D(geoCoordinates); + _add2DTexture(geoCoordinates); // A centered 2D map marker to indicate the exact location. // Note that 3D map markers are always drawn on top of 2D map markers. @@ -243,7 +258,23 @@ class MapItemsExample { _locationIndicatorList.add(locationIndicator); } - void _addFlatMarker3D(GeoCoordinates geoCoordinates) { + void _addFlatMarker(GeoCoordinates geoCoordinates) async { + + Uint8List imagePixelData = await _loadFileAsUint8List('assets/poi.png'); + MapImage mapImage = MapImage.withPixelDataAndImageFormat(imagePixelData, ImageFormat.png); + + // The default scale factor of the map marker is 1.0. For a scale of 2, the map marker becomes 2x larger. + // For a scale of 0.5, the map marker shrinks to half of its original size. + double scaleFactor = 0.5; + + // With DENSITY_INDEPENDENT_PIXELS the map marker will have a constant size on the screen regardless if the map is zoomed in or out. + MapMarker3D mapMarker3D = MapMarker3D.fromImage(geoCoordinates,mapImage, scaleFactor, RenderSizeUnit.densityIndependentPixels); + + _hereMapController.mapScene.addMapMarker3d(mapMarker3D); + _mapMarker3DList.add(mapMarker3D); + } + + void _add2DTexture(GeoCoordinates geoCoordinates) { // Place the files in the "assets" directory as specified in pubspec.yaml. // Adjust file name and path as appropriate for your project. // Note: The bottom of the plane is centered on the origin. diff --git a/examples/latest/explore/flutter/map_items_app/lib/main.dart b/examples/latest/explore/flutter/map_items_app/lib/main.dart index 4ac2c080..99ff2ab9 100644 --- a/examples/latest/explore/flutter/map_items_app/lib/main.dart +++ b/examples/latest/explore/flutter/map_items_app/lib/main.dart @@ -97,7 +97,11 @@ class _MyAppState extends State { } void _flatMapMarkersButtonClicked() { - _mapItemsExample?.showFlatMapMarkers(); + _mapItemsExample?.showFlatMapMarker(); + } + + void _2DTextureButtonClicked() { + _mapItemsExample?.show2DTexture(); } void _mapMarkers3DButtonClicked() { @@ -185,7 +189,8 @@ class _MyAppState extends State { MenuSectionItem("Anchored (2D)", _anchoredMapMarkersButtonClicked), MenuSectionItem("Centered (2D)", _centeredMapMarkersButtonClicked), MenuSectionItem("MapMarkerCluster", _mapMarkerClusterButtonClicked), - MenuSectionItem("Flat", _flatMapMarkersButtonClicked), + MenuSectionItem("Flat MapMarker", _flatMapMarkersButtonClicked), + MenuSectionItem("2DTexture", _2DTextureButtonClicked), MenuSectionItem("3D OBJ", _mapMarkers3DButtonClicked), ]; diff --git a/examples/latest/explore/ios/Camera/README.md b/examples/latest/explore/ios/Camera/README.md index a4731a60..3d461098 100644 --- a/examples/latest/explore/ios/Camera/README.md +++ b/examples/latest/explore/ios/Camera/README.md @@ -3,7 +3,7 @@ The Canera example app shows how to change the target anchor point and how to mo Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/CameraKeyframeTracks/README.md b/examples/latest/explore/ios/CameraKeyframeTracks/README.md index a723af6c..a27df383 100644 --- a/examples/latest/explore/ios/CameraKeyframeTracks/README.md +++ b/examples/latest/explore/ios/CameraKeyframeTracks/README.md @@ -3,7 +3,7 @@ The CameraKeyframeTracks example app shows how to use multiple keyframe tracks f Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/CustomMapStylesExplore/README.md b/examples/latest/explore/ios/CustomMapStylesExplore/README.md index 3b26c8b5..3d3249ce 100644 --- a/examples/latest/explore/ios/CustomMapStylesExplore/README.md +++ b/examples/latest/explore/ios/CustomMapStylesExplore/README.md @@ -3,7 +3,7 @@ This example app shows how to load custom maps. You can find how this is done in Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/Contents.json b/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/Contents.json new file mode 100644 index 00000000..1d8ce251 --- /dev/null +++ b/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "poi@1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "poi@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "poi@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@1x.png b/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@1x.png new file mode 100644 index 00000000..c288ce06 Binary files /dev/null and b/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@1x.png differ diff --git a/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@2x.png b/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@2x.png new file mode 100644 index 00000000..9ce63731 Binary files /dev/null and b/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@2x.png differ diff --git a/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@3x.png b/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@3x.png new file mode 100644 index 00000000..63841c53 Binary files /dev/null and b/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@3x.png differ diff --git a/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/CustomRasterLayersExample.swift b/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/CustomRasterLayersExample.swift index 961117d2..98ebe467 100644 --- a/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/CustomRasterLayersExample.swift +++ b/examples/latest/explore/ios/CustomRasterLayers/CustomRasterLayers/CustomRasterLayersExample.swift @@ -42,6 +42,9 @@ class CustomRasterLayersExample { // We want to start with the default map style. rasterMapLayerTonerStyle.setEnabled(false) + + // Add a POI marker + addPOIMapMarker(geoCoordinates: GeoCoordinates(latitude: 52.530932, longitude: 13.384915)) } func onEnableButtonClicked() { @@ -61,10 +64,13 @@ class CustomRasterLayersExample { let templateUrl = "https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png" // The storage levels available for this data source. Supported range [0, 31]. let storageLevels: [Int32] = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] - let rasterProviderConfig = RasterDataSourceConfiguration.Provider(templateUrl: templateUrl, + var rasterProviderConfig = RasterDataSourceConfiguration.Provider(templateUrl: templateUrl, tilingScheme: TilingScheme.quadTreeMercator, storageLevels: storageLevels) + // If you want to add transparent layers then set this to true. + rasterProviderConfig.hasAlphaChannel = false + // Raster tiles are stored in a separate cache on the device. let path = "cache/raster/toner" let maxDiskSizeInBytes: Int64 = 1024 * 1024 * 32 @@ -79,8 +85,8 @@ class CustomRasterLayersExample { } private func createMapLayer(dataSourceName: String) -> MapLayer { - // The layer should be rendered on top of other layers. - let priority = MapLayerPriorityBuilder().renderedLast().build() + // The layer should be rendered on top of other layers except the cartography layer consisting of the embedded Carto POI markers. + let priority = MapLayerPriorityBuilder().renderedLast().renderedAfterLayer(named: "ocm_cartography").build() // And it should be visible for all zoom levels. let range = MapLayerVisibilityRange(minimumZoomLevel: 0, maximumZoomLevel: 22 + 1) @@ -101,4 +107,23 @@ class CustomRasterLayersExample { fatalError("MapLayer creation failed Cause: \(InstantiationException)") } } + + private func addPOIMapMarker(geoCoordinates: GeoCoordinates) { + guard + let image = UIImage(named: "poi.png"), + let imageData = image.pngData() else { + print("Error: Image not found.") + return + } + + // The bottom, middle position should point to the location. + // By default, the anchor point is set to 0.5, 0.5. + let anchorPoint = Anchor2D(horizontal: 0.5, vertical: 1) + let mapMarker = MapMarker(at: geoCoordinates, + image: MapImage(pixelData: imageData, + imageFormat: ImageFormat.png), + anchor: anchorPoint) + + mapView.mapScene.addMapMarker(mapMarker) + } } diff --git a/examples/latest/explore/ios/CustomRasterLayers/README.md b/examples/latest/explore/ios/CustomRasterLayers/README.md index a9ae84fa..a2ead035 100644 --- a/examples/latest/explore/ios/CustomRasterLayers/README.md +++ b/examples/latest/explore/ios/CustomRasterLayers/README.md @@ -3,7 +3,7 @@ This example app shows how to load custom raster layers. You can find how this i Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/CustomRasterLayers/assets/poi_texture.png b/examples/latest/explore/ios/CustomRasterLayers/assets/poi_texture.png new file mode 100644 index 00000000..40a543ae Binary files /dev/null and b/examples/latest/explore/ios/CustomRasterLayers/assets/poi_texture.png differ diff --git a/examples/latest/explore/ios/EVRouting/EVRouting/RoutingExample.swift b/examples/latest/explore/ios/EVRouting/EVRouting/RoutingExample.swift index 52c0afd7..15f48875 100644 --- a/examples/latest/explore/ios/EVRouting/EVRouting/RoutingExample.swift +++ b/examples/latest/explore/ios/EVRouting/EVRouting/RoutingExample.swift @@ -95,12 +95,18 @@ class RoutingExample { 60: 0.196, 90: 0.238] - // Ensure that the vehicle does not run out of energy along the way and charging stations are added as additional waypoints. + // Must be 0 for isoline calculation. + evCarOptions.routeOptions.alternatives = 0 + + // Ensure that the vehicle does not run out of energy along the way + // and charging stations are added as additional waypoints. evCarOptions.ensureReachability = true - // The below options are required when setting the ensureReachability option to true. + // The below options are required when setting the ensureReachability option to true + // (AvoidanceOptions need to be empty). + evCarOptions.avoidanceOptions = AvoidanceOptions() + evCarOptions.routeOptions.speedCapInMetersPerSecond = nil evCarOptions.routeOptions.optimizationMode = .fastest - evCarOptions.routeOptions.alternatives = 0 evCarOptions.batterySpecifications.connectorTypes = [.tesla, .iec62196Type1Combo, .iec62196Type2Combo] evCarOptions.batterySpecifications.totalCapacityInKilowattHours = 80.0 evCarOptions.batterySpecifications.initialChargeInKilowattHours = 10.0 diff --git a/examples/latest/explore/ios/EVRouting/README.md b/examples/latest/explore/ios/EVRouting/README.md index 643d24b9..1c7ba539 100644 --- a/examples/latest/explore/ios/EVRouting/README.md +++ b/examples/latest/explore/ios/EVRouting/README.md @@ -3,7 +3,7 @@ The EVRouting example app shows how the HERE SDK can be used to calculate routes Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/Gestures/README.md b/examples/latest/explore/ios/Gestures/README.md index b8f01f21..d8410aee 100644 --- a/examples/latest/explore/ios/Gestures/README.md +++ b/examples/latest/explore/ios/Gestures/README.md @@ -3,7 +3,7 @@ The Gesture example app shows how to handle common map interactions and gestures Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/HelloMap/README.md b/examples/latest/explore/ios/HelloMap/README.md index 079d8a35..206a6017 100644 --- a/examples/latest/explore/ios/HelloMap/README.md +++ b/examples/latest/explore/ios/HelloMap/README.md @@ -3,7 +3,7 @@ The HelloMap example app shows how the HERE SDK can be integrated into your proj Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/HelloMapCarPlay/README.md b/examples/latest/explore/ios/HelloMapCarPlay/README.md index 64852d5a..665d5c24 100644 --- a/examples/latest/explore/ios/HelloMapCarPlay/README.md +++ b/examples/latest/explore/ios/HelloMapCarPlay/README.md @@ -3,9 +3,9 @@ The HelloMapCarPlay example app shows how [CarPlay](https://www.apple.com/de/ios Build instructions: ------------------- -1) Edit `HelloMapCarPlay/HelloMapCarPlay/Entitlements.plist` to uncomment the key for testing purposes. For a production-ready app, [contact Apple](https://developer.apple.com/documentation/carplay/requesting_carplay_entitlements) to include the required entitlements in your provisioning profile for signing the app. Until then, this app cannot be tested on a real device. Use an iOS simulator instead. From the simulator menu bar, choose _I/O -> External Displays -> CarPlay_ to show the CarPlay head unit simulator on your development machine. +1) Edit `HelloMapCarPlay/HelloMapCarPlay/Entitlements.plist` to uncomment the key for testing purposes. For a production-ready app, [contact Apple](https://developer.apple.com/documentation/carplay/requesting_carplay_entitlements) to include the required entitlements in your provisioning profile for signing the app. Until then, this app cannot be tested on a real device. Use an iOS simulator instead (>= min supported iOS version of HERE SDK). From the simulator menu bar, choose _I/O -> External Displays -> CarPlay_ to show the CarPlay head unit simulator on your development machine. -2) Copy the `heresdk.xcframework` file to your app's root folder. +2) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/HelloMapWithStoryboard/README.md b/examples/latest/explore/ios/HelloMapWithStoryboard/README.md index ec777dc0..5cf6238c 100644 --- a/examples/latest/explore/ios/HelloMapWithStoryboard/README.md +++ b/examples/latest/explore/ios/HelloMapWithStoryboard/README.md @@ -3,7 +3,7 @@ The HelloMapWithStoryboard example app shows how to build your UI from Xcode’s Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/MapItems/MapItems/MapItemsExample.swift b/examples/latest/explore/ios/MapItems/MapItems/MapItemsExample.swift index 80ffd9a9..379da062 100644 --- a/examples/latest/explore/ios/MapItems/MapItems/MapItemsExample.swift +++ b/examples/latest/explore/ios/MapItems/MapItems/MapItemsExample.swift @@ -130,8 +130,22 @@ class MapItemsExample: TapDelegate { let geoCoordinates = createRandomGeoCoordinatesAroundMapCenter() + // It's origin is centered on the location. + addFlatMarker(geoCoordinates: geoCoordinates) + + // A centered 2D map marker to indicate the exact location. + // Note that 3D map markers are always drawn on top of 2D map markers. + addCircleMapMarker(geoCoordinates: geoCoordinates) + } + + public func on2DTextureButtonClicked() { + // Tilt the map for a better 3D effect. + tiltMap() + + let geoCoordinates = createRandomGeoCoordinatesAroundMapCenter() + // Adds a flat POI marker that rotates and tilts together with the map. - addFlatMarker3D(geoCoordinates: geoCoordinates) + add2DTexture(geoCoordinates: geoCoordinates) // A centered 2D map marker to indicate the exact location. // Note that 3D map markers are always drawn on top of 2D map markers. @@ -208,11 +222,11 @@ class MapItemsExample: TapDelegate { let mapMarker = MapMarker(at: geoCoordinates, image: MapImage(pixelData: imageData, imageFormat: ImageFormat.png)) - + // Optionally, enable a fade in-out animation. let durationInSeconds: TimeInterval = 3 mapMarker.fadeDuration = durationInSeconds - + mapView.mapScene.addMapMarker(mapMarker) mapMarkers.append(mapMarker) } @@ -245,7 +259,7 @@ class MapItemsExample: TapDelegate { } } - private func addFlatMarker3D(geoCoordinates: GeoCoordinates) { + private func add2DTexture(geoCoordinates: GeoCoordinates) { // Place the files to an "assets" directory via drag & drop. // Adjust file name and path as appropriate for your project. // Note: The bottom of the plane is centered on the origin. @@ -263,6 +277,27 @@ class MapItemsExample: TapDelegate { mapMarkers3D.append(mapMarker3D) } + private func addFlatMarker(geoCoordinates: GeoCoordinates) { + guard + let image = UIImage(named: "poi.png"), + let imageData = image.pngData() else { + print("Error: Image not found.") + return + } + + // The default scale factor of the map marker is 1.0. For a scale of 2, the map marker becomes 2x larger. + // For a scale of 0.5, the map marker shrinks to half of its original size. + let scaleFactor: Double = 0.5 + + let mapImage:MapImage = MapImage(pixelData: imageData, imageFormat: ImageFormat.png) + + // With DENSITY_INDEPENDENT_PIXELS the map marker will have a constant size on the screen regardless if the map is zoomed in or out. + let mapMarker3D: MapMarker3D = MapMarker3D(at: geoCoordinates, image: mapImage, scale: scaleFactor, unit: RenderSize.Unit.densityIndependentPixels) + + mapView.mapScene.addMapMarker3d(mapMarker3D) + mapMarkers3D.append(mapMarker3D) + } + private func addMapMarker3D(geoCoordinates: GeoCoordinates) { // Place the files to an "assets" directory via drag & drop. // Adjust file name and path as appropriate for your project. @@ -271,16 +306,16 @@ class MapItemsExample: TapDelegate { // Without depth check, 3D models are rendered on top of everything. With depth check enabled, // it may be hidden by buildings. In addition: - // If a 3D object has its center at the origin of its internal coordinate system, + // If a 3D object has its center at the origin of its internal coordinate system, // then parts of it may be rendered below the ground surface (altitude < 0). - // Note that the HERE SDK map surface is flat, following a Mercator or Globe projection. + // Note that the HERE SDK map surface is flat, following a Mercator or Globe projection. // Therefore, a 3D object becomes visible when the altitude of its location is 0 or higher. // By default, without setting a scale factor, 1 unit in 3D coordinate space equals 1 meter. - let geoCoordinatesWithAltitude = GeoCoordinates(latitude: geoCoordinates.latitude, - longitude: geoCoordinates.longitude, - altitude: 18.0) + let geoCoordinatesWithAltitude = GeoCoordinates(latitude: geoCoordinates.latitude, + longitude: geoCoordinates.longitude, + altitude: 18.0) let mapMarker3DModel = MapMarker3DModel(geometryFilePath: geometryFile, textureFilePath: textureFile) - let mapMarker3D = MapMarker3D(at: geoCoordinatesWithAltitude, model: mapMarker3DModel) + let mapMarker3D = MapMarker3D(at: geoCoordinatesWithAltitude, model: mapMarker3DModel) mapMarker3D.scale = 6 mapMarker3D.isDepthCheckEnabled = true @@ -330,12 +365,12 @@ class MapItemsExample: TapDelegate { if let groupingList = pickedMapItems?.clusteredMarkers { handlePickedMapMarkerClusters(groupingList) } - + // Note that 3D map markers can't be picked yet. Only marker, polgon and polyline map items are pickable. guard let topmostMapMarker = pickedMapItems?.markers.first else { return } - + if let message = topmostMapMarker.metadata?.getString(key: "key_poi") { showDialog(title: "Map Marker picked", message: message) return @@ -348,7 +383,7 @@ class MapItemsExample: TapDelegate { guard let topmostGrouping = groupingList.first else { return } - + let clusterSize = topmostGrouping.markers.count if (clusterSize == 0) { // This cluster does not contain any MapMarker items. @@ -361,7 +396,7 @@ class MapItemsExample: TapDelegate { message: "Number of contained markers in this cluster: \(clusterSize). Total number of markers in this MapMarkerCluster: \(topmostGrouping.parent.markers.count)") } } - + private func createRandomGeoCoordinatesAroundMapCenter() -> GeoCoordinates { let scaleFactor = UIScreen.main.scale let mapViewWidthInPixels = Double(mapView.bounds.width * scaleFactor) diff --git a/examples/latest/explore/ios/MapItems/MapItems/ViewController.swift b/examples/latest/explore/ios/MapItems/MapItems/ViewController.swift index 98f7eaa7..ac2986d0 100644 --- a/examples/latest/explore/ios/MapItems/MapItems/ViewController.swift +++ b/examples/latest/explore/ios/MapItems/MapItems/ViewController.swift @@ -50,7 +50,7 @@ final class ViewController: UIViewController { mapViewPinsExample = MapViewPinsExample(mapView: mapView) isMapSceneLoaded = true } - + override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() mapView.handleLowMemory() @@ -67,49 +67,55 @@ final class ViewController: UIViewController { @IBAction func onMenuButtonClicked(_ sender: UIBarButtonItem) { performSegue(withIdentifier: "showMenu", sender: nil) } - + private func onAnchoredButtonClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onAnchoredButtonClicked() } } - + private func onCenteredButtonClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onCenteredButtonClicked() } } - + private func onMapMarkerClusterButtonClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onMapMarkerClusterButtonClicked() } } - + private func onLocationIndicatorPedestrianButtonClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onLocationIndicatorPedestrianButtonClicked() } } - + private func onLocationIndicatorNavigationButtonClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onLocationIndicatorNavigationButtonClicked() } } - + private func onLocationIndicatorStateClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.toggleActiveStateForLocationIndicator() } } - + private func onFlatMapMarkerButtonClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onFlatMapMarkerButtonClicked() } } + private func on2DTextureButtonClicked(_ sender: Any) { + if isMapSceneLoaded { + mapItemsExample.on2DTextureButtonClicked() + } + } + private func onMapMarker3DClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onMapMarker3DClicked() @@ -176,7 +182,8 @@ final class ViewController: UIViewController { MenuItem(title: "Anchored (2D)", onSelect: onAnchoredButtonClicked), MenuItem(title: "Centered (2D)", onSelect: onCenteredButtonClicked), MenuItem(title: "MapMarkerCluster", onSelect: onMapMarkerClusterButtonClicked), - MenuItem(title: "Flat", onSelect: onFlatMapMarkerButtonClicked), + MenuItem(title: "Flat Marker", onSelect: onFlatMapMarkerButtonClicked), + MenuItem(title: "2D Texture", onSelect: on2DTextureButtonClicked), MenuItem(title: "3D Marker", onSelect: onMapMarker3DClicked) ]) } diff --git a/examples/latest/explore/ios/MapItems/README.md b/examples/latest/explore/ios/MapItems/README.md index 33462b90..798b1d78 100644 --- a/examples/latest/explore/ios/MapItems/README.md +++ b/examples/latest/explore/ios/MapItems/README.md @@ -3,7 +3,7 @@ The MapItems example app shows how to pin images and 3D objects to mark specific Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/PublicTransit/README.md b/examples/latest/explore/ios/PublicTransit/README.md index 7a52afb7..5b5b57fd 100644 --- a/examples/latest/explore/ios/PublicTransit/README.md +++ b/examples/latest/explore/ios/PublicTransit/README.md @@ -3,7 +3,7 @@ The Public Transit example app shows how to calculate a public transport route f Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/Routing/README.md b/examples/latest/explore/ios/Routing/README.md index ba372532..83ce031f 100644 --- a/examples/latest/explore/ios/Routing/README.md +++ b/examples/latest/explore/ios/Routing/README.md @@ -3,7 +3,7 @@ The Routing example app shows how to calculate a route from A to B with a number Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/Search/README.md b/examples/latest/explore/ios/Search/README.md index 9ff30cd9..7b7aee06 100644 --- a/examples/latest/explore/ios/Search/README.md +++ b/examples/latest/explore/ios/Search/README.md @@ -3,7 +3,7 @@ The Search example app shows how to search for places including auto suggestions Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/StandAloneEngine/README.md b/examples/latest/explore/ios/StandAloneEngine/README.md index d2843dc1..a9a7d052 100644 --- a/examples/latest/explore/ios/StandAloneEngine/README.md +++ b/examples/latest/explore/ios/StandAloneEngine/README.md @@ -3,7 +3,7 @@ The StandAloneEngine example app shows how to use an engine without a map view. Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/Traffic/README.md b/examples/latest/explore/ios/Traffic/README.md index f1dcea3d..1df233eb 100644 --- a/examples/latest/explore/ios/Traffic/README.md +++ b/examples/latest/explore/ios/Traffic/README.md @@ -3,7 +3,7 @@ The Traffic example app shows how to toggle traffic flow and traffic incidents v Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/explore/ios/UnitTesting/README.md b/examples/latest/explore/ios/UnitTesting/README.md index 77c47ceb..6f3a9fe9 100644 --- a/examples/latest/explore/ios/UnitTesting/README.md +++ b/examples/latest/explore/ios/UnitTesting/README.md @@ -3,7 +3,7 @@ The UnitTesting example app shows how the HERE SDK can be mocked in unit tests. Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/lite/android/CameraLite/app/src/main/AndroidManifest.xml b/examples/latest/lite/android/CameraLite/app/src/main/AndroidManifest.xml index 98c09285..9c2c3777 100644 --- a/examples/latest/lite/android/CameraLite/app/src/main/AndroidManifest.xml +++ b/examples/latest/lite/android/CameraLite/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/lite/android/CameraLite/app/src/main/java/com/here/sdk/camera/MainActivity.java b/examples/latest/lite/android/CameraLite/app/src/main/java/com/here/sdk/camera/MainActivity.java index c2d6f013..bbe49578 100644 --- a/examples/latest/lite/android/CameraLite/app/src/main/java/com/here/sdk/camera/MainActivity.java +++ b/examples/latest/lite/android/CameraLite/app/src/main/java/com/here/sdk/camera/MainActivity.java @@ -95,25 +95,27 @@ public void moveToXYButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/lite/android/GesturesLite/app/src/main/AndroidManifest.xml b/examples/latest/lite/android/GesturesLite/app/src/main/AndroidManifest.xml index 4d6a9206..faf27f8f 100644 --- a/examples/latest/lite/android/GesturesLite/app/src/main/AndroidManifest.xml +++ b/examples/latest/lite/android/GesturesLite/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/lite/android/GesturesLite/app/src/main/java/com/here/gestures/MainActivity.java b/examples/latest/lite/android/GesturesLite/app/src/main/java/com/here/gestures/MainActivity.java index ccee1387..7ddedde3 100644 --- a/examples/latest/lite/android/GesturesLite/app/src/main/java/com/here/gestures/MainActivity.java +++ b/examples/latest/lite/android/GesturesLite/app/src/main/java/com/here/gestures/MainActivity.java @@ -86,25 +86,27 @@ public void onLoadScene(@Nullable MapScene.ErrorCode errorCode) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/lite/android/HelloMapLite/app/src/main/AndroidManifest.xml b/examples/latest/lite/android/HelloMapLite/app/src/main/AndroidManifest.xml index e3f576c4..bf11a4ff 100644 --- a/examples/latest/lite/android/HelloMapLite/app/src/main/AndroidManifest.xml +++ b/examples/latest/lite/android/HelloMapLite/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/lite/android/HelloMapLite/app/src/main/java/com/here/hellomap/MainActivity.java b/examples/latest/lite/android/HelloMapLite/app/src/main/java/com/here/hellomap/MainActivity.java index c10e6399..67f4fd40 100644 --- a/examples/latest/lite/android/HelloMapLite/app/src/main/java/com/here/hellomap/MainActivity.java +++ b/examples/latest/lite/android/HelloMapLite/app/src/main/java/com/here/hellomap/MainActivity.java @@ -88,25 +88,27 @@ public void onLoadScene(@Nullable MapScene.ErrorCode errorCode) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); - } + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); + } + super.onDestroy(); } } diff --git a/examples/latest/lite/android/MapItemsLite/app/src/main/AndroidManifest.xml b/examples/latest/lite/android/MapItemsLite/app/src/main/AndroidManifest.xml index 726da8f2..e0c806a2 100644 --- a/examples/latest/lite/android/MapItemsLite/app/src/main/AndroidManifest.xml +++ b/examples/latest/lite/android/MapItemsLite/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/lite/android/MapItemsLite/app/src/main/java/com/here/mapitems/MainActivity.java b/examples/latest/lite/android/MapItemsLite/app/src/main/java/com/here/mapitems/MainActivity.java index 0fb485db..ef0ac121 100644 --- a/examples/latest/lite/android/MapItemsLite/app/src/main/java/com/here/mapitems/MainActivity.java +++ b/examples/latest/lite/android/MapItemsLite/app/src/main/java/com/here/mapitems/MainActivity.java @@ -124,26 +124,28 @@ public void onLoadScene(@Nullable MapScene.ErrorCode errorCode) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } @Override diff --git a/examples/latest/lite/android/RoutingLite/app/src/main/AndroidManifest.xml b/examples/latest/lite/android/RoutingLite/app/src/main/AndroidManifest.xml index 20c034f6..c5eef4e1 100644 --- a/examples/latest/lite/android/RoutingLite/app/src/main/AndroidManifest.xml +++ b/examples/latest/lite/android/RoutingLite/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/lite/android/RoutingLite/app/src/main/java/com/here/routing/MainActivity.java b/examples/latest/lite/android/RoutingLite/app/src/main/java/com/here/routing/MainActivity.java index b758c16e..d8ebf707 100644 --- a/examples/latest/lite/android/RoutingLite/app/src/main/java/com/here/routing/MainActivity.java +++ b/examples/latest/lite/android/RoutingLite/app/src/main/java/com/here/routing/MainActivity.java @@ -100,25 +100,27 @@ public void clearMapButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); - } + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); + } + super.onDestroy(); } } diff --git a/examples/latest/lite/android/SearchLite/app/src/main/AndroidManifest.xml b/examples/latest/lite/android/SearchLite/app/src/main/AndroidManifest.xml index e9f683af..98221588 100644 --- a/examples/latest/lite/android/SearchLite/app/src/main/AndroidManifest.xml +++ b/examples/latest/lite/android/SearchLite/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/lite/android/SearchLite/app/src/main/java/com/here/search/MainActivity.java b/examples/latest/lite/android/SearchLite/app/src/main/java/com/here/search/MainActivity.java index 24218e07..7880402d 100644 --- a/examples/latest/lite/android/SearchLite/app/src/main/java/com/here/search/MainActivity.java +++ b/examples/latest/lite/android/SearchLite/app/src/main/java/com/here/search/MainActivity.java @@ -99,25 +99,27 @@ public void geocodeAnAddressButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/lite/android/StandAloneEngineLite/app/src/main/AndroidManifest.xml b/examples/latest/lite/android/StandAloneEngineLite/app/src/main/AndroidManifest.xml index 19083e82..a35f4c42 100644 --- a/examples/latest/lite/android/StandAloneEngineLite/app/src/main/AndroidManifest.xml +++ b/examples/latest/lite/android/StandAloneEngineLite/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/lite/android/StandAloneEngineLite/app/src/main/java/com/here/sdk/standaloneengine/MainActivity.java b/examples/latest/lite/android/StandAloneEngineLite/app/src/main/java/com/here/sdk/standaloneengine/MainActivity.java index dd5a28f5..81d8e85a 100644 --- a/examples/latest/lite/android/StandAloneEngineLite/app/src/main/java/com/here/sdk/standaloneengine/MainActivity.java +++ b/examples/latest/lite/android/StandAloneEngineLite/app/src/main/java/com/here/sdk/standaloneengine/MainActivity.java @@ -102,12 +102,13 @@ public void onSearchCompleted(SearchError searchError, List list) { @Override protected void onDestroy() { - super.onDestroy(); - // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/lite/android/TrafficLite/app/src/main/AndroidManifest.xml b/examples/latest/lite/android/TrafficLite/app/src/main/AndroidManifest.xml index 7ede1610..4d7ebf55 100644 --- a/examples/latest/lite/android/TrafficLite/app/src/main/AndroidManifest.xml +++ b/examples/latest/lite/android/TrafficLite/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/lite/android/TrafficLite/app/src/main/java/com/here/traffic/MainActivity.java b/examples/latest/lite/android/TrafficLite/app/src/main/java/com/here/traffic/MainActivity.java index 812a7a46..a9e453c9 100644 --- a/examples/latest/lite/android/TrafficLite/app/src/main/java/com/here/traffic/MainActivity.java +++ b/examples/latest/lite/android/TrafficLite/app/src/main/java/com/here/traffic/MainActivity.java @@ -96,25 +96,27 @@ public void disableAllButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/lite/ios/CameraLite/README.md b/examples/latest/lite/ios/CameraLite/README.md index a4731a60..3d461098 100644 --- a/examples/latest/lite/ios/CameraLite/README.md +++ b/examples/latest/lite/ios/CameraLite/README.md @@ -3,7 +3,7 @@ The Canera example app shows how to change the target anchor point and how to mo Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/lite/ios/GesturesLite/README.md b/examples/latest/lite/ios/GesturesLite/README.md index e11110a7..3f3f7436 100644 --- a/examples/latest/lite/ios/GesturesLite/README.md +++ b/examples/latest/lite/ios/GesturesLite/README.md @@ -3,7 +3,7 @@ The Gesture example app shows how to handle common map interactions and gestures Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/lite/ios/HelloMapLite/README.md b/examples/latest/lite/ios/HelloMapLite/README.md index 079d8a35..206a6017 100644 --- a/examples/latest/lite/ios/HelloMapLite/README.md +++ b/examples/latest/lite/ios/HelloMapLite/README.md @@ -3,7 +3,7 @@ The HelloMap example app shows how the HERE SDK can be integrated into your proj Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/lite/ios/HelloMapWithStoryboardLite/README.md b/examples/latest/lite/ios/HelloMapWithStoryboardLite/README.md index fc431007..25c42884 100644 --- a/examples/latest/lite/ios/HelloMapWithStoryboardLite/README.md +++ b/examples/latest/lite/ios/HelloMapWithStoryboardLite/README.md @@ -3,7 +3,7 @@ The HelloMapWithStoryboard example app shows how to build your UI from Xcode’s Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/lite/ios/MapItemsLite/README.md b/examples/latest/lite/ios/MapItemsLite/README.md index 05c23e81..8ec337c1 100644 --- a/examples/latest/lite/ios/MapItemsLite/README.md +++ b/examples/latest/lite/ios/MapItemsLite/README.md @@ -3,7 +3,7 @@ The MapItems example app shows how to pin images and native views to mark specif Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/lite/ios/RoutingLite/README.md b/examples/latest/lite/ios/RoutingLite/README.md index a35da17c..e3622d33 100644 --- a/examples/latest/lite/ios/RoutingLite/README.md +++ b/examples/latest/lite/ios/RoutingLite/README.md @@ -3,7 +3,7 @@ The Routing example app shows how to calculate a route from A to B with a number Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/lite/ios/SearchLite/README.md b/examples/latest/lite/ios/SearchLite/README.md index 6121ff99..60046150 100644 --- a/examples/latest/lite/ios/SearchLite/README.md +++ b/examples/latest/lite/ios/SearchLite/README.md @@ -3,7 +3,7 @@ The Search example app shows how to search for places including auto suggestions Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/lite/ios/StandAloneEngineLite/README.md b/examples/latest/lite/ios/StandAloneEngineLite/README.md index 9c3cf1b7..76d86841 100644 --- a/examples/latest/lite/ios/StandAloneEngineLite/README.md +++ b/examples/latest/lite/ios/StandAloneEngineLite/README.md @@ -3,7 +3,7 @@ The StandAloneEngine example app shows how to use an engine without a map view. Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/lite/ios/TrafficLite/README.md b/examples/latest/lite/ios/TrafficLite/README.md index 002300b2..b476f46b 100644 --- a/examples/latest/lite/ios/TrafficLite/README.md +++ b/examples/latest/lite/ios/TrafficLite/README.md @@ -3,7 +3,7 @@ The Traffic example app shows how to toggle traffic flow and traffic incidents v Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/android/Camera/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/Camera/app/src/main/AndroidManifest.xml index 98c09285..9c2c3777 100644 --- a/examples/latest/navigate/android/Camera/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/Camera/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/Camera/app/src/main/java/com/here/sdk/camera/MainActivity.java b/examples/latest/navigate/android/Camera/app/src/main/java/com/here/sdk/camera/MainActivity.java index bb75be9e..7130aba0 100644 --- a/examples/latest/navigate/android/Camera/app/src/main/java/com/here/sdk/camera/MainActivity.java +++ b/examples/latest/navigate/android/Camera/app/src/main/java/com/here/sdk/camera/MainActivity.java @@ -96,25 +96,27 @@ public void moveToXYButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/AndroidManifest.xml index 5510c41b..e5f7438e 100644 --- a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> @@ -27,4 +28,4 @@ - \ No newline at end of file + diff --git a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/CameraKeyframeTracksExample.java b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/CameraKeyframeTracksExample.java index 3e4d1d76..842e722a 100644 --- a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/CameraKeyframeTracksExample.java +++ b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/CameraKeyframeTracksExample.java @@ -21,9 +21,11 @@ import android.util.Log; -import com.here.camerakeyframetracks.models.LocationKeyframeModel; -import com.here.camerakeyframetracks.models.OrientationKeyframeModel; -import com.here.camerakeyframetracks.models.ScalarKeyframeModel; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.here.sdk.animation.AnimationListener; +import com.here.sdk.animation.AnimationState; import com.here.sdk.animation.EasingFunction; import com.here.sdk.animation.GeoCoordinatesKeyframe; import com.here.sdk.animation.GeoOrientationKeyframe; @@ -43,128 +45,145 @@ public class CameraKeyframeTracksExample { + private static final String TAG = CameraKeyframeTracksExample.class.getName(); + private final MapView mapView; - private List tracks = new ArrayList<>(); public CameraKeyframeTracksExample(MapView mapView) { this.mapView = mapView; } public void startTripToNYC() { - // This animation can be started and replayed. When started, it will always start from globe view. - List tracks = createTripToNYCAnimation(); - startTripToNYCAnimation(tracks); + List mapCameraKeyframeTracks = createMapCameraKeyframeTracks(); + + MapCameraAnimation mapCameraAnimation; + + try { + mapCameraAnimation = MapCameraAnimationFactory.createAnimation(mapCameraKeyframeTracks); + } catch (MapCameraAnimation.InstantiationException e) { + Log.e(TAG, e.error.name()); + return; + } + + // This animation can be started and replayed. When started, it will always start from the first keyframe. + mapView.getCamera().startAnimation(mapCameraAnimation, new AnimationListener() { + @Override + public void onAnimationStateChanged(@NonNull AnimationState animationState) { + switch (animationState) { + case STARTED: + Log.d(TAG, "Animation started."); + break; + case CANCELLED: + Log.d(TAG, "Animation cancelled."); + break; + case COMPLETED: + Log.d(TAG, "Animation finished."); + break; + } + } + }); } public void stopTripToNYCAnimation() { mapView.getCamera().cancelAnimations(); } - private List createLocationsForTripToNYC() { - List locationList = new ArrayList<>(); + @Nullable + private List createMapCameraKeyframeTracks() { + MapCameraKeyframeTrack geoCoordinatesMapCameraKeyframeTrack; + MapCameraKeyframeTrack scalarMapCameraKeyframeTrack; + MapCameraKeyframeTrack geoOrientationMapCameraKeyframeTrack; - Collections.addAll( - locationList, - new LocationKeyframeModel(new GeoCoordinates(40.685869754854544, -74.02550202768754), Duration.ofMillis(0)), // Statue of Liberty - new LocationKeyframeModel(new GeoCoordinates(40.69051652745291, -74.04455943649657), Duration.ofMillis(5000)), // Statue of Liberty - new LocationKeyframeModel(new GeoCoordinates(40.69051652745291, -74.04455943649657), Duration.ofMillis(7000)), // Statue of Liberty - new LocationKeyframeModel(new GeoCoordinates(40.69051652745291, -74.04455943649657), Duration.ofMillis(9000)), // Statue of Liberty - new LocationKeyframeModel(new GeoCoordinates(40.690266839135, -74.01237515471776), Duration.ofMillis(5000)), // Governor Island - new LocationKeyframeModel(new GeoCoordinates(40.7116777285189, -74.01248494562448), Duration.ofMillis(6000)), // World Trade Center - new LocationKeyframeModel(new GeoCoordinates(40.71083291395444, -74.01226399217569), Duration.ofMillis(6000)), // World Trade Center - new LocationKeyframeModel(new GeoCoordinates(40.719259512385506, -74.01171007254635), Duration.ofMillis(5000)), // Manhattan College - new LocationKeyframeModel(new GeoCoordinates(40.73603959180013, -73.98968489844603), Duration.ofMillis(6000)), // Union Square - new LocationKeyframeModel(new GeoCoordinates(40.741732824650214, -73.98825255774022), Duration.ofMillis(5000)), // Flatiron - new LocationKeyframeModel(new GeoCoordinates(40.74870637098952, -73.98515306630678), Duration.ofMillis(6000)), // Empire State Building - new LocationKeyframeModel(new GeoCoordinates(40.742693509776856, -73.95937093336781), Duration.ofMillis(3000)), // Queens Midtown - new LocationKeyframeModel(new GeoCoordinates(40.75065611103842, -73.96053139022635), Duration.ofMillis(4000)), // Roosevelt Island - new LocationKeyframeModel(new GeoCoordinates(40.756823163883794, -73.95461519921352), Duration.ofMillis(4000)), // Queens Bridge - new LocationKeyframeModel(new GeoCoordinates(40.763573707276784, -73.94571562970638), Duration.ofMillis(4000)), // Roosevelt Bridge - new LocationKeyframeModel(new GeoCoordinates(40.773052036400294, -73.94027981305442), Duration.ofMillis(3000)), // Roosevelt Lighthouse - new LocationKeyframeModel(new GeoCoordinates(40.78270548734745, -73.92189566092568), Duration.ofMillis(3000)), // Hell gate Bridge - new LocationKeyframeModel(new GeoCoordinates(40.78406704306872, -73.91746017917936), Duration.ofMillis(2000)), // Ralph Park - new LocationKeyframeModel(new GeoCoordinates(40.768075472169045, -73.97446921306035), Duration.ofMillis(2000)), // Wollman Rink - new LocationKeyframeModel(new GeoCoordinates(40.78255966255712, -73.9586425508515), Duration.ofMillis(3000)) // Solomon Museum - ); - - return locationList; - } - - private List createOrientationsForTripToNYC() { - List orientationList = new ArrayList<>(); + List geoCoordinatesKeyframes = createGeoCoordinatesKeyframes(); + List scalarKeyframes = createScalarKeyframes(); + List geoOrientationKeyframes = createGeoOrientationKeyframes(); - Collections.addAll( - orientationList, - new OrientationKeyframeModel(new GeoOrientation(30, 60), Duration.ofMillis(0)), - new OrientationKeyframeModel(new GeoOrientation(-40, 80), Duration.ofMillis(6000)), - new OrientationKeyframeModel(new GeoOrientation(30, 70), Duration.ofMillis(6000)), - new OrientationKeyframeModel(new GeoOrientation(70, 30), Duration.ofMillis(4000)), - new OrientationKeyframeModel(new GeoOrientation(-30, 70), Duration.ofMillis(5000)), - new OrientationKeyframeModel(new GeoOrientation(30, 70), Duration.ofMillis(5000)), - new OrientationKeyframeModel(new GeoOrientation(40, 70), Duration.ofMillis(5000)), - new OrientationKeyframeModel(new GeoOrientation(80, 40), Duration.ofMillis(5000)), - new OrientationKeyframeModel(new GeoOrientation(30, 70), Duration.ofMillis(5000)) - ); - - return orientationList; - } + try { + geoCoordinatesMapCameraKeyframeTrack = MapCameraKeyframeTrack.lookAtTarget(geoCoordinatesKeyframes, EasingFunction.LINEAR, KeyframeInterpolationMode.LINEAR); + scalarMapCameraKeyframeTrack = MapCameraKeyframeTrack.lookAtDistance(scalarKeyframes, EasingFunction.LINEAR, KeyframeInterpolationMode.LINEAR); + geoOrientationMapCameraKeyframeTrack = MapCameraKeyframeTrack.lookAtOrientation(geoOrientationKeyframes, EasingFunction.LINEAR, KeyframeInterpolationMode.LINEAR); + } catch (MapCameraKeyframeTrack.InstantiationException e) { + // Throws an error if keyframes are empty or the duration of keyframes is invalid. + Log.e(TAG, e.toString()); + return null; + } - private List createScalarsForTripToNYC() { - List scalarList = new ArrayList<>(); + // Add different kinds of animation tracks that can be played back simultaneously. + // Each track can have a different total duration. + // The animation completes, when the longest track has been competed. + List mapCameraKeyframeTracks = new ArrayList<>(); - scalarList.add(new ScalarKeyframeModel(80000000.0, Duration.ofMillis(0))); - scalarList.add(new ScalarKeyframeModel(8000000.0, Duration.ofMillis(2000))); - scalarList.add(new ScalarKeyframeModel(8000.0, Duration.ofMillis(2000))); - scalarList.add(new ScalarKeyframeModel(1000.0, Duration.ofMillis(2000))); - scalarList.add(new ScalarKeyframeModel(500.0, Duration.ofMillis(3000))); + // This changes the camera's location over time. + mapCameraKeyframeTracks.add(geoCoordinatesMapCameraKeyframeTrack); + // This changes the camera's distance (= scalar) to earth over time. + mapCameraKeyframeTracks.add(scalarMapCameraKeyframeTrack); + // This changes the camera's orientation over time. + mapCameraKeyframeTracks.add(geoOrientationMapCameraKeyframeTrack); - return scalarList; + return mapCameraKeyframeTracks; } - private List createTripToNYCAnimation() { - // A list of location key frames for moving the map camera from one geo coordinate to another. - List locationKeyframesList = new ArrayList<>(); - List locationList = createLocationsForTripToNYC(); - - for (LocationKeyframeModel locationKeyframeModel: locationList) { - locationKeyframesList.add(new GeoCoordinatesKeyframe(locationKeyframeModel.geoCoordinates , locationKeyframeModel.duration)); - } - - // A list of geo orientation keyframes for changing the map camera orientation. - List orientationKeyframeList = new ArrayList<>(); - List orientationList = createOrientationsForTripToNYC(); + private List createGeoCoordinatesKeyframes() { + List geoCoordinatesKeyframes = new ArrayList<>(); - for (OrientationKeyframeModel orientationKeyframeModel: orientationList) { - orientationKeyframeList.add(new GeoOrientationKeyframe(orientationKeyframeModel.geoOrientation , orientationKeyframeModel.duration)); - } + // The duration indicates the time it takes to reach the GeoCoordinates of the keyframe. + Collections.addAll( + geoCoordinatesKeyframes, + new GeoCoordinatesKeyframe(new GeoCoordinates(40.685869754854544, -74.02550202768754), Duration.ofMillis(0)), // Statue of Liberty + new GeoCoordinatesKeyframe(new GeoCoordinates(40.69051652745291, -74.04455943649657), Duration.ofMillis(5000)), // Statue of Liberty + new GeoCoordinatesKeyframe(new GeoCoordinates(40.69051652745291, -74.04455943649657), Duration.ofMillis(7000)), // Statue of Liberty + new GeoCoordinatesKeyframe(new GeoCoordinates(40.69051652745291, -74.04455943649657), Duration.ofMillis(9000)), // Statue of Liberty + new GeoCoordinatesKeyframe(new GeoCoordinates(40.690266839135, -74.01237515471776), Duration.ofMillis(5000)), // Governor Island + new GeoCoordinatesKeyframe(new GeoCoordinates(40.7116777285189, -74.01248494562448), Duration.ofMillis(6000)), // World Trade Center + new GeoCoordinatesKeyframe(new GeoCoordinates(40.71083291395444, -74.01226399217569), Duration.ofMillis(6000)), // World Trade Center + new GeoCoordinatesKeyframe(new GeoCoordinates(40.719259512385506, -74.01171007254635), Duration.ofMillis(5000)), // Manhattan College + new GeoCoordinatesKeyframe(new GeoCoordinates(40.73603959180013, -73.98968489844603), Duration.ofMillis(6000)), // Union Square + new GeoCoordinatesKeyframe(new GeoCoordinates(40.741732824650214, -73.98825255774022), Duration.ofMillis(5000)), // Flatiron + new GeoCoordinatesKeyframe(new GeoCoordinates(40.74870637098952, -73.98515306630678), Duration.ofMillis(6000)), // Empire State Building + new GeoCoordinatesKeyframe(new GeoCoordinates(40.742693509776856, -73.95937093336781), Duration.ofMillis(3000)), // Queens Midtown + new GeoCoordinatesKeyframe(new GeoCoordinates(40.75065611103842, -73.96053139022635), Duration.ofMillis(4000)), // Roosevelt Island + new GeoCoordinatesKeyframe(new GeoCoordinates(40.756823163883794, -73.95461519921352), Duration.ofMillis(4000)), // Queens Bridge + new GeoCoordinatesKeyframe(new GeoCoordinates(40.763573707276784, -73.94571562970638), Duration.ofMillis(4000)), // Roosevelt Bridge + new GeoCoordinatesKeyframe(new GeoCoordinates(40.773052036400294, -73.94027981305442), Duration.ofMillis(3000)), // Roosevelt Lighthouse + new GeoCoordinatesKeyframe(new GeoCoordinates(40.78270548734745, -73.92189566092568), Duration.ofMillis(3000)), // Hell gate Bridge + new GeoCoordinatesKeyframe(new GeoCoordinates(40.78406704306872, -73.91746017917936), Duration.ofMillis(2000)), // Ralph Park + new GeoCoordinatesKeyframe(new GeoCoordinates(40.768075472169045, -73.97446921306035), Duration.ofMillis(2000)), // Wollman Rink + new GeoCoordinatesKeyframe(new GeoCoordinates(40.78255966255712, -73.9586425508515), Duration.ofMillis(3000))); // Solomon Museum + + return geoCoordinatesKeyframes; + } - // A list of scalar key frames for changing the map camera distance from the earth. + private List createScalarKeyframes() { List scalarKeyframesList = new ArrayList<>(); - List scalarList = createScalarsForTripToNYC(); - for (ScalarKeyframeModel scalarKeyframeModel: scalarList) { - scalarKeyframesList.add(new ScalarKeyframe(scalarKeyframeModel.scalar, scalarKeyframeModel.duration)); - } - - try { - // Creating a track to add different kinds of animations to the MapCameraKeyframeTrack. - tracks = new ArrayList<>(); - tracks.add(MapCameraKeyframeTrack.lookAtDistance(scalarKeyframesList, EasingFunction.LINEAR, KeyframeInterpolationMode.LINEAR)); - tracks.add(MapCameraKeyframeTrack.lookAtTarget(locationKeyframesList, EasingFunction.LINEAR, KeyframeInterpolationMode.LINEAR)); - tracks.add(MapCameraKeyframeTrack.lookAtOrientation(orientationKeyframeList, EasingFunction.LINEAR, KeyframeInterpolationMode.LINEAR)); - } catch (MapCameraKeyframeTrack.InstantiationException e) { - // Throws an error if keyframes is empty or duration of keyframes are invalid. - Log.e("KeyframeTrackTag", e.toString()); - } - - return tracks; + // The duration indicates the time it takes to reach the scalar (= camera distance in meters) of the keyframe. + Collections.addAll( + scalarKeyframesList, + new ScalarKeyframe(80000000.0, Duration.ofMillis(0)), + new ScalarKeyframe(8000000.0, Duration.ofMillis(2000)), + new ScalarKeyframe(8000.0, Duration.ofMillis(2000)), + new ScalarKeyframe(1000.0, Duration.ofMillis(2000)), + new ScalarKeyframe(500.0, Duration.ofMillis(3000))); + + return scalarKeyframesList; } - private void startTripToNYCAnimation(List tracks) { - try { - mapView.getCamera().startAnimation(MapCameraAnimationFactory.createAnimation(tracks)); - } catch (MapCameraAnimation.InstantiationException e) { - Log.e("KeyframeAnimationTag", e.error.name()); - } + private List createGeoOrientationKeyframes() { + List geoOrientationKeyframeList = new ArrayList<>(); + + // The duration indicates the time it takes to achieve the GeoOrientation of the keyframe. + Collections.addAll( + geoOrientationKeyframeList, + new GeoOrientationKeyframe(new GeoOrientation(30, 60) , Duration.ofMillis(0)), + new GeoOrientationKeyframe(new GeoOrientation(-40, 80), Duration.ofMillis(6000)), + new GeoOrientationKeyframe(new GeoOrientation(30, 70), Duration.ofMillis(6000)), + new GeoOrientationKeyframe(new GeoOrientation(70, 30), Duration.ofMillis(4000)), + new GeoOrientationKeyframe(new GeoOrientation(-30, 70), Duration.ofMillis(5000)), + new GeoOrientationKeyframe(new GeoOrientation(30, 70), Duration.ofMillis(5000)), + new GeoOrientationKeyframe(new GeoOrientation(40, 70), Duration.ofMillis(5000)), + new GeoOrientationKeyframe(new GeoOrientation(80, 40), Duration.ofMillis(5000)), + new GeoOrientationKeyframe(new GeoOrientation(30, 70), Duration.ofMillis(5000))); + + return geoOrientationKeyframeList; } } diff --git a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/MainActivity.java b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/MainActivity.java index e0f545be..bb94629d 100644 --- a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/MainActivity.java +++ b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/MainActivity.java @@ -19,7 +19,6 @@ package com.here.camerakeyframetracks; -import android.annotation.SuppressLint; import android.os.Bundle; import android.util.Log; import android.view.Menu; @@ -30,8 +29,6 @@ import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; -import com.here.camerakeyframetracks.helper.PermissionsRequestor; -import com.here.camerakeyframetracks.helper.RouteCalculator; import com.here.sdk.core.GeoCoordinates; import com.here.sdk.core.engine.SDKNativeEngine; import com.here.sdk.mapview.MapError; @@ -76,9 +73,9 @@ public void permissionsDenied() { }); } - @SuppressLint("MissingSuperCall") @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults); permissionsRequestor.onRequestPermissionsResult(requestCode, grantResults); } @@ -107,18 +104,13 @@ public boolean onCreateOptionsMenu(Menu menu) { @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { - if (RouteCalculator.testRoute == null) { - Log.e("MainActivity", "Error: No route for testing ..."); - return false; - } - switch (item.getItemId()) { case R.id.stopToRouteAnimation: routeAnimationExample.stopRouteAnimation(); return true; case R.id.startToRouteAnimation: // An animation that moves the camera to the route without keyframe tracks. - routeAnimationExample.animateToRoute(RouteCalculator.testRoute); + routeAnimationExample.animateToRoute(); return true; case R.id.startNYCAnimation: // A camera animation through New York. @@ -134,25 +126,27 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/helper/PermissionsRequestor.java b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/PermissionsRequestor.java similarity index 98% rename from examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/helper/PermissionsRequestor.java rename to examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/PermissionsRequestor.java index 429d64df..027dd17b 100644 --- a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/helper/PermissionsRequestor.java +++ b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/PermissionsRequestor.java @@ -17,7 +17,7 @@ * License-Filename: LICENSE */ -package com.here.camerakeyframetracks.helper; +package com.here.camerakeyframetracks; import android.Manifest; import android.app.Activity; diff --git a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteAnimationExample.java b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteAnimationExample.java index d58d1073..a200f110 100644 --- a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteAnimationExample.java +++ b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteAnimationExample.java @@ -21,7 +21,6 @@ import android.util.Log; -import com.here.camerakeyframetracks.helper.RouteCalculator; import com.here.sdk.animation.EasingFunction; import com.here.sdk.core.GeoOrientationUpdate; import com.here.sdk.core.Point2D; @@ -52,16 +51,25 @@ public void stopRouteAnimation() { mapView.getCamera().cancelAnimations(); } - public void animateToRoute(Route route) { - // Untilt and unrotate the map. + public void animateToRoute() { + if (RouteCalculator.testRoute == null) { + Log.e("RouteAnimationExample", "Error: No route for testing ..."); + return; + } + + animateToRoute(RouteCalculator.testRoute); + } + + private void animateToRoute(Route route) { + // The animation should result in an untilted and unrotated map. double bearing = 0; double tilt = 0; - // We want to show the route fitting in the map view without any additional padding. - Point2D origin = new Point2D(0, 0); - Size2D sizeInPixels = new Size2D(mapView.getWidth(), mapView.getHeight()); + // We want to show the route fitting in the map view with an additional padding of 50 pixels + Point2D origin = new Point2D(50, 50); + Size2D sizeInPixels = new Size2D(mapView.getWidth() - 100, mapView.getHeight() - 100); Rectangle2D mapViewport = new Rectangle2D(origin, sizeInPixels); - // Animate to route. + // Animate to the route within a duration of 3 seconds. MapCameraUpdate update = MapCameraUpdateFactory.lookAt( route.getBoundingBox(), new GeoOrientationUpdate(bearing, tilt), diff --git a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/helper/RouteCalculator.java b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteCalculator.java similarity index 80% rename from examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/helper/RouteCalculator.java rename to examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteCalculator.java index ccbb9748..5b01d70b 100644 --- a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/helper/RouteCalculator.java +++ b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/RouteCalculator.java @@ -17,7 +17,7 @@ * License-Filename: LICENSE */ -package com.here.camerakeyframetracks.helper; +package com.here.camerakeyframetracks; import android.util.Log; @@ -29,11 +29,9 @@ import com.here.sdk.core.errors.InstantiationErrorException; import com.here.sdk.mapview.MapPolyline; import com.here.sdk.mapview.MapView; -import com.here.sdk.routing.CalculateRouteCallback; import com.here.sdk.routing.CarOptions; import com.here.sdk.routing.Route; import com.here.sdk.routing.RoutingEngine; -import com.here.sdk.routing.RoutingError; import com.here.sdk.routing.Waypoint; import java.util.ArrayList; @@ -60,19 +58,16 @@ public RouteCalculator(MapView mapView) { } public void createRoute() { - // A random test route. + // A fixed test route. Waypoint startWaypoint = new Waypoint(new GeoCoordinates(40.7133, -74.0112)); Waypoint destinationWaypoint = new Waypoint(new GeoCoordinates(40.7203, -74.3122)); List waypoints = new ArrayList<>(Arrays.asList(startWaypoint, destinationWaypoint)); - routingEngine.calculateRoute(waypoints, new CarOptions(), new CalculateRouteCallback() { - @Override - public void onRouteCalculated(@Nullable RoutingError routingError, @Nullable List routes) { - if (routingError == null) { - testRoute = routes.get(0); - showRouteOnMap(testRoute); - } else { - Log.e("RouteCalculator", "RoutingError: " + routingError.name()); - } + routingEngine.calculateRoute(waypoints, new CarOptions(), (routingError, routes) -> { + if (routingError == null) { + testRoute = routes.get(0); + showRouteOnMap(testRoute); + } else { + Log.e("RouteCalculator", "RoutingError: " + routingError.name()); } }); } diff --git a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/LocationKeyframeModel.java b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/LocationKeyframeModel.java deleted file mode 100644 index 9b013ac3..00000000 --- a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/LocationKeyframeModel.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.here.camerakeyframetracks.models; - -import com.here.sdk.core.GeoCoordinates; -import com.here.time.Duration; - -// A data class meant to be used for the creation of GeoCoordinatesKeyframe instances that hold -// a GeoCoordinates object and the animation duration to reach these coordinates. -public class LocationKeyframeModel { - public GeoCoordinates geoCoordinates; - public Duration duration; - - public LocationKeyframeModel(GeoCoordinates geoCoordinates, Duration duration) { - this.geoCoordinates = geoCoordinates; - this.duration = duration; - } -} diff --git a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/OrientationKeyframeModel.java b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/OrientationKeyframeModel.java deleted file mode 100644 index 0b6fe6c0..00000000 --- a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/OrientationKeyframeModel.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.here.camerakeyframetracks.models; - -import com.here.sdk.core.GeoOrientation; -import com.here.time.Duration; - -// A data class meant to be used for the creation of GeoOrientationKeyframe instances that hold -// a GeoOrientation and the animation duration to reach the GeoOrientation. -public class OrientationKeyframeModel { - public GeoOrientation geoOrientation; - public Duration duration; - - public OrientationKeyframeModel(GeoOrientation geoOrientation, Duration duration) { - this.geoOrientation = geoOrientation; - this.duration = duration; - } -} diff --git a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/ScalarKeyframeModel.java b/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/ScalarKeyframeModel.java deleted file mode 100644 index b41230d1..00000000 --- a/examples/latest/navigate/android/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/models/ScalarKeyframeModel.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.here.camerakeyframetracks.models; - -import com.here.time.Duration; - -// A data class meant to be used for the creation of ScalarKeyframe instances that hold -// a distance in meters and the animation duration to reach this distance. -public class ScalarKeyframeModel { - public Double scalar; - public Duration duration; - - public ScalarKeyframeModel(Double scalar, Duration duration) { - this.scalar = scalar; - this.duration = duration; - } -} diff --git a/examples/latest/navigate/android/CartoPOIPicking/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/CartoPOIPicking/app/src/main/AndroidManifest.xml index 040807bd..3e974a20 100644 --- a/examples/latest/navigate/android/CartoPOIPicking/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/CartoPOIPicking/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/CartoPOIPicking/app/src/main/java/com/here/cartopoipicking/MainActivity.java b/examples/latest/navigate/android/CartoPOIPicking/app/src/main/java/com/here/cartopoipicking/MainActivity.java index fefcc3ff..6c50a646 100644 --- a/examples/latest/navigate/android/CartoPOIPicking/app/src/main/java/com/here/cartopoipicking/MainActivity.java +++ b/examples/latest/navigate/android/CartoPOIPicking/app/src/main/java/com/here/cartopoipicking/MainActivity.java @@ -185,26 +185,28 @@ public void onPlaceIdSearchCompleted(@Nullable SearchError searchError, @Nullabl @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } private void showDialog(String title, String message) { diff --git a/examples/latest/navigate/android/CustomMapStylesNavigate/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/CustomMapStylesNavigate/app/src/main/AndroidManifest.xml index 6f2e50e5..bb8dff62 100644 --- a/examples/latest/navigate/android/CustomMapStylesNavigate/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/CustomMapStylesNavigate/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/CustomMapStylesNavigate/app/src/main/java/com/here/sdk/custommapstyles/MainActivity.java b/examples/latest/navigate/android/CustomMapStylesNavigate/app/src/main/java/com/here/sdk/custommapstyles/MainActivity.java index 578ec00d..753faf29 100644 --- a/examples/latest/navigate/android/CustomMapStylesNavigate/app/src/main/java/com/here/sdk/custommapstyles/MainActivity.java +++ b/examples/latest/navigate/android/CustomMapStylesNavigate/app/src/main/java/com/here/sdk/custommapstyles/MainActivity.java @@ -92,25 +92,27 @@ public void unloadButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/CustomRasterLayers/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/CustomRasterLayers/app/src/main/AndroidManifest.xml index 27e66755..b8e25e23 100644 --- a/examples/latest/navigate/android/CustomRasterLayers/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/CustomRasterLayers/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/CustomRasterLayersExample.java b/examples/latest/navigate/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/CustomRasterLayersExample.java index e096738b..1a62d084 100644 --- a/examples/latest/navigate/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/CustomRasterLayersExample.java +++ b/examples/latest/navigate/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/CustomRasterLayersExample.java @@ -19,14 +19,21 @@ package com.here.sdk.customrasterlayers; + import android.content.Context; + + import com.here.sdk.core.Anchor2D; import com.here.sdk.core.GeoCoordinates; + import com.here.sdk.core.Metadata; import com.here.sdk.mapview.MapCamera; import com.here.sdk.mapview.MapContentType; + import com.here.sdk.mapview.MapImage; + import com.here.sdk.mapview.MapImageFactory; import com.here.sdk.mapview.MapLayer; import com.here.sdk.mapview.MapLayerBuilder; import com.here.sdk.mapview.MapLayerPriority; import com.here.sdk.mapview.MapLayerPriorityBuilder; import com.here.sdk.mapview.MapLayerVisibilityRange; + import com.here.sdk.mapview.MapMarker; import com.here.sdk.mapview.MapMeasure; import com.here.sdk.mapview.MapView; import com.here.sdk.mapview.datasource.RasterDataSource; @@ -43,9 +50,11 @@ public class CustomRasterLayersExample { private MapView mapView; private MapLayer rasterMapLayerTonerStyle; private RasterDataSource rasterDataSourceTonerStyle; + private Context context; - public void onMapSceneLoaded(MapView mapView) { + public void onMapSceneLoaded(MapView mapView, Context context) { this.mapView = mapView; + this.context = context; MapCamera camera = mapView.getCamera(); MapMeasure mapMeasureZoom = new MapMeasure(MapMeasure.Kind.DISTANCE, DEFAULT_DISTANCE_TO_EARTH_IN_METERS); @@ -57,6 +66,9 @@ public void onMapSceneLoaded(MapView mapView) { // We want to start with the default map style. rasterMapLayerTonerStyle.setEnabled(false); + + // Add a POI marker + addPOIMapMarker(new GeoCoordinates(52.530932, 13.384915)); } public void enableButtonClicked() { @@ -81,6 +93,9 @@ private RasterDataSource createRasterDataSource(String dataSourceName) { TilingScheme.QUAD_TREE_MERCATOR, storageLevels); + // If you want to add transparent layers then set this to true. + rasterProviderConfig.hasAlphaChannel = false; + // Raster tiles are stored in a separate cache on the device. String path = "cache/raster/toner"; long maxDiskSizeInBytes = 1024 * 1024 * 32; @@ -92,8 +107,8 @@ private RasterDataSource createRasterDataSource(String dataSourceName) { } private MapLayer createMapLayer(String dataSourceName) { - // The layer should be rendered on top of other layers. - MapLayerPriority priority = new MapLayerPriorityBuilder().renderedLast().build(); + // The layer should be rendered on top of other layers except the cartography layer consisting of the embedded Carto POI markers. + MapLayerPriority priority = new MapLayerPriorityBuilder().renderedLast().renderedAfterLayer("ocm_cartography").build(); // And it should be visible for all zoom levels. MapLayerVisibilityRange range = new MapLayerVisibilityRange(0, 22 + 1); @@ -116,4 +131,15 @@ public void onDestroy() { rasterMapLayerTonerStyle.destroy(); rasterDataSourceTonerStyle.destroy(); } + + private void addPOIMapMarker(GeoCoordinates geoCoordinates) { + MapImage mapImage = MapImageFactory.fromResource(context.getResources(), R.drawable.poi); + + // The bottom, middle position should point to the location. + // By default, the anchor point is set to 0.5, 0.5. + Anchor2D anchor2D = new Anchor2D(0.5F, 1); + MapMarker mapMarker = new MapMarker(geoCoordinates, mapImage, anchor2D); + + mapView.getMapScene().addMapMarker(mapMarker); + } } diff --git a/examples/latest/navigate/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/MainActivity.java b/examples/latest/navigate/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/MainActivity.java index e0ecdcde..85b844da 100644 --- a/examples/latest/navigate/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/MainActivity.java +++ b/examples/latest/navigate/android/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/MainActivity.java @@ -74,7 +74,7 @@ private void loadMapScene() { public void onLoadScene(@Nullable MapError mapError) { if (mapError == null) { customRasterLayersExample = new CustomRasterLayersExample(); - customRasterLayersExample.onMapSceneLoaded(mapView); + customRasterLayersExample.onMapSceneLoaded(mapView, MainActivity.this); } else { Log.d(TAG, "onLoadScene failed: " + mapError.toString()); } @@ -92,28 +92,29 @@ public void disableButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); - customRasterLayersExample.onDestroy(); mapView.onDestroy(); - + // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/CustomRasterLayers/app/src/main/res/drawable/poi.png b/examples/latest/navigate/android/CustomRasterLayers/app/src/main/res/drawable/poi.png new file mode 100644 index 00000000..808c67e5 Binary files /dev/null and b/examples/latest/navigate/android/CustomRasterLayers/app/src/main/res/drawable/poi.png differ diff --git a/examples/latest/navigate/android/EVRouting/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/EVRouting/app/src/main/AndroidManifest.xml index 19d2dc16..a12abaf6 100644 --- a/examples/latest/navigate/android/EVRouting/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/EVRouting/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/EVRouting/app/src/main/java/com/here/evrouting/EVRoutingExample.java b/examples/latest/navigate/android/EVRouting/app/src/main/java/com/here/evrouting/EVRoutingExample.java index 6d4271ea..838c7bf9 100644 --- a/examples/latest/navigate/android/EVRouting/app/src/main/java/com/here/evrouting/EVRoutingExample.java +++ b/examples/latest/navigate/android/EVRouting/app/src/main/java/com/here/evrouting/EVRoutingExample.java @@ -40,6 +40,7 @@ import com.here.sdk.mapview.MapPolygon; import com.here.sdk.mapview.MapPolyline; import com.here.sdk.mapview.MapView; +import com.here.sdk.routing.AvoidanceOptions; import com.here.sdk.routing.CalculateIsolineCallback; import com.here.sdk.routing.CalculateRouteCallback; import com.here.sdk.routing.ChargingConnectorType; @@ -152,12 +153,18 @@ private EVCarOptions getEVCarOptions() { put(90, 0.238); }}; - // Ensure that the vehicle does not run out of energy along the way and charging stations are added as additional waypoints. + // Must be 0 for isoline calculation. + evCarOptions.routeOptions.alternatives = 0; + + // Ensure that the vehicle does not run out of energy along the way + // and charging stations are added as additional waypoints. evCarOptions.ensureReachability = true; - // The below options are required when setting the ensureReachability option to true. + // The below options are required when setting the ensureReachability option to true + // (AvoidanceOptions need to be empty). + evCarOptions.avoidanceOptions = new AvoidanceOptions(); + evCarOptions.routeOptions.speedCapInMetersPerSecond = null; evCarOptions.routeOptions.optimizationMode = OptimizationMode.FASTEST; - evCarOptions.routeOptions.alternatives = 0; evCarOptions.batterySpecifications.connectorTypes = new ArrayList<>(Arrays.asList(ChargingConnectorType.TESLA, ChargingConnectorType.IEC_62196_TYPE_1_COMBO, ChargingConnectorType.IEC_62196_TYPE_2_COMBO)); diff --git a/examples/latest/navigate/android/EVRouting/app/src/main/java/com/here/evrouting/MainActivity.java b/examples/latest/navigate/android/EVRouting/app/src/main/java/com/here/evrouting/MainActivity.java index 54f96a6e..6cd902ea 100644 --- a/examples/latest/navigate/android/EVRouting/app/src/main/java/com/here/evrouting/MainActivity.java +++ b/examples/latest/navigate/android/EVRouting/app/src/main/java/com/here/evrouting/MainActivity.java @@ -100,25 +100,27 @@ public void clearMapButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/Gestures/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/Gestures/app/src/main/AndroidManifest.xml index 4d6a9206..faf27f8f 100644 --- a/examples/latest/navigate/android/Gestures/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/Gestures/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/Gestures/app/src/main/java/com/here/gestures/MainActivity.java b/examples/latest/navigate/android/Gestures/app/src/main/java/com/here/gestures/MainActivity.java index 2c241354..6a756586 100644 --- a/examples/latest/navigate/android/Gestures/app/src/main/java/com/here/gestures/MainActivity.java +++ b/examples/latest/navigate/android/Gestures/app/src/main/java/com/here/gestures/MainActivity.java @@ -87,25 +87,27 @@ public void onLoadScene(@Nullable MapError mapError) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/HelloMap/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/HelloMap/app/src/main/AndroidManifest.xml index af30eacc..3f669d9c 100644 --- a/examples/latest/navigate/android/HelloMap/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/HelloMap/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/HelloMap/app/src/main/java/com/here/hellomap/MainActivity.java b/examples/latest/navigate/android/HelloMap/app/src/main/java/com/here/hellomap/MainActivity.java index f7f98eaf..aca22909 100644 --- a/examples/latest/navigate/android/HelloMap/app/src/main/java/com/here/hellomap/MainActivity.java +++ b/examples/latest/navigate/android/HelloMap/app/src/main/java/com/here/hellomap/MainActivity.java @@ -105,25 +105,27 @@ public void onLoadScene(@Nullable MapError mapError) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/HelloMapAndroidAuto/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/HelloMapAndroidAuto/app/src/main/AndroidManifest.xml index beb69b0a..ab7a4178 100644 --- a/examples/latest/navigate/android/HelloMapAndroidAuto/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/HelloMapAndroidAuto/app/src/main/AndroidManifest.xml @@ -23,7 +23,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/HelloMapAndroidAuto/app/src/main/java/com/here/hellomapandroidauto/MainActivity.java b/examples/latest/navigate/android/HelloMapAndroidAuto/app/src/main/java/com/here/hellomapandroidauto/MainActivity.java index 39601a84..2c53b017 100644 --- a/examples/latest/navigate/android/HelloMapAndroidAuto/app/src/main/java/com/here/hellomapandroidauto/MainActivity.java +++ b/examples/latest/navigate/android/HelloMapAndroidAuto/app/src/main/java/com/here/hellomapandroidauto/MainActivity.java @@ -104,25 +104,27 @@ public void onLoadScene(@Nullable MapError mapError) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/HelloMapKotlin/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/HelloMapKotlin/app/src/main/AndroidManifest.xml index af30eacc..3f669d9c 100644 --- a/examples/latest/navigate/android/HelloMapKotlin/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/HelloMapKotlin/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/HelloMapKotlin/app/src/main/java/com/here/hellomap/MainActivity.kt b/examples/latest/navigate/android/HelloMapKotlin/app/src/main/java/com/here/hellomap/MainActivity.kt index f0e2281f..8d8e16de 100644 --- a/examples/latest/navigate/android/HelloMapKotlin/app/src/main/java/com/here/hellomap/MainActivity.kt +++ b/examples/latest/navigate/android/HelloMapKotlin/app/src/main/java/com/here/hellomap/MainActivity.kt @@ -81,24 +81,28 @@ class MainActivity : AppCompatActivity() { } override fun onPause() { - super.onPause() mapView?.onPause() + super.onPause() } override fun onResume() { - super.onResume() mapView?.onResume() + super.onResume() } override fun onDestroy() { - super.onDestroy() mapView?.onDestroy() // Free HERE SDK resources before the application shuts down. SDKNativeEngine.getSharedInstance()?.dispose() + + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null) + + super.onDestroy() } companion object { private val TAG = MainActivity::class.java.simpleName } -} \ No newline at end of file +} diff --git a/examples/latest/navigate/android/IndoorMap/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/IndoorMap/app/src/main/AndroidManifest.xml index 99b1cd68..95f997a1 100644 --- a/examples/latest/navigate/android/IndoorMap/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/IndoorMap/app/src/main/AndroidManifest.xml @@ -20,7 +20,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/IndoorMap/app/src/main/java/com/here/sdk/examples/venues/MainActivity.java b/examples/latest/navigate/android/IndoorMap/app/src/main/java/com/here/sdk/examples/venues/MainActivity.java index c1ec7a52..03c3ccd0 100644 --- a/examples/latest/navigate/android/IndoorMap/app/src/main/java/com/here/sdk/examples/venues/MainActivity.java +++ b/examples/latest/navigate/android/IndoorMap/app/src/main/java/com/here/sdk/examples/venues/MainActivity.java @@ -31,6 +31,7 @@ import com.here.sdk.core.GeoCoordinates; import com.here.sdk.core.engine.SDKNativeEngine; +import com.here.sdk.core.errors.InstantiationErrorException; import com.here.sdk.examples.venues.PermissionsRequestor.ResultListener; import com.here.sdk.gestures.TapListener; import com.here.sdk.mapview.MapMeasure; @@ -119,7 +120,12 @@ private void loadMapScene() { // Create a venue engine object. Once the initialization is done, a callback // will be called. - venueEngine = new VenueEngine(this ::onVenueEngineInitCompleted); + try { + venueEngine = new VenueEngine(this ::onVenueEngineInitCompleted); + } catch (InstantiationErrorException e) { + Log.e(TAG, "SDK Engine instantiation failed"); + e.printStackTrace(); + } } else { Log.d(TAG, "Loading map failed: mapError: " + mapError.name()); } @@ -272,7 +278,6 @@ protected void onResume() { @Override protected void onDestroy() { - super.onDestroy(); if (mapView != null) { mapView.getGestures().setTapListener(null); mapView.getGestures().setLongPressListener(null); @@ -284,6 +289,9 @@ protected void onDestroy() { SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/MapItems/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/MapItems/app/src/main/AndroidManifest.xml index 726da8f2..e0c806a2 100644 --- a/examples/latest/navigate/android/MapItems/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/MapItems/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/MapItems/app/src/main/java/com/here/mapitems/MainActivity.java b/examples/latest/navigate/android/MapItems/app/src/main/java/com/here/mapitems/MainActivity.java index 730db59a..c5d38175 100644 --- a/examples/latest/navigate/android/MapItems/app/src/main/java/com/here/mapitems/MainActivity.java +++ b/examples/latest/navigate/android/MapItems/app/src/main/java/com/here/mapitems/MainActivity.java @@ -103,26 +103,28 @@ public void onLoadScene(@Nullable MapError mapError) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } @Override @@ -171,8 +173,11 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) { case R.id.active_inactive_menu_item: mapItemsExample.toggleActiveStateForLocationIndicator(); return true; + case R.id.flat_menu_item_image: + mapItemsExample.showFlatMapMarker(); + return true; case R.id.flat_menu_item: - mapItemsExample.showFlatMarker(); + mapItemsExample.show2DTexture(); return true; case R.id.obj_3D_menu_item: mapItemsExample.showMapMarker3D(); diff --git a/examples/latest/navigate/android/MapItems/app/src/main/java/com/here/mapitems/MapItemsExample.java b/examples/latest/navigate/android/MapItems/app/src/main/java/com/here/mapitems/MapItemsExample.java index caa1451a..c220bcb3 100644 --- a/examples/latest/navigate/android/MapItems/app/src/main/java/com/here/mapitems/MapItemsExample.java +++ b/examples/latest/navigate/android/MapItems/app/src/main/java/com/here/mapitems/MapItemsExample.java @@ -45,6 +45,7 @@ import com.here.sdk.mapview.MapView; import com.here.sdk.mapview.MapViewBase; import com.here.sdk.mapview.PickMapItemsResult; +import com.here.sdk.mapview.RenderSize; import com.here.time.Duration; import java.io.IOException; @@ -134,14 +135,14 @@ public void showLocationIndicatorNavigation() { addLocationIndicator(geoCoordinates, LocationIndicator.IndicatorStyle.NAVIGATION); } - public void showFlatMarker() { + public void show2DTexture() { // Tilt the map for a better 3D effect. tiltMap(); GeoCoordinates geoCoordinates = createRandomGeoCoordinatesAroundMapCenter(); // Adds a flat POI marker that rotates and tilts together with the map. - addFlatMarker3D(geoCoordinates); + add2DTexture(geoCoordinates); // A centered 2D map marker to indicate the exact location. // Note that 3D map markers are always drawn on top of 2D map markers. @@ -159,6 +160,19 @@ public void showMapMarker3D() { addMapMarker3D(geoCoordinates); } + public void showFlatMapMarker() { + // Tilt the map for a better 3D effect. + tiltMap(); + + GeoCoordinates geoCoordinates = createRandomGeoCoordinatesAroundMapCenter(); + + // It's origin is centered on the location. + addFlatMarker(geoCoordinates); + + // A centered 2D map marker to indicate the exact location. + addCircleMapMarker(geoCoordinates); + } + public void clearMap() { mapView.getMapScene().removeMapMarkers(mapMarkerList); mapMarkerList.clear(); @@ -242,7 +256,7 @@ public void toggleActiveStateForLocationIndicator() { } } - private void addFlatMarker3D(GeoCoordinates geoCoordinates) { + private void add2DTexture(GeoCoordinates geoCoordinates) { // Place the files in the "assets" directory. // Full path example: app/src/main/assets/plane.obj // Adjust file name and path as appropriate for your project. @@ -263,6 +277,20 @@ private void addFlatMarker3D(GeoCoordinates geoCoordinates) { mapMarker3DList.add(mapMarker3D); } + private void addFlatMarker(GeoCoordinates geoCoordinates) { + MapImage mapImage = MapImageFactory.fromResource(context.getResources(), R.drawable.poi); + + // The default scale factor of the map marker is 1.0. For a scale of 2, the map marker becomes 2x larger. + // For a scale of 0.5, the map marker shrinks to half of its original size. + double scaleFactor = 0.5; + + // With DENSITY_INDEPENDENT_PIXELS the map marker will have a constant size on the screen regardless if the map is zoomed in or out. + MapMarker3D mapMarker3D = new MapMarker3D(geoCoordinates, mapImage, scaleFactor, RenderSize.Unit.DENSITY_INDEPENDENT_PIXELS); + + mapView.getMapScene().addMapMarker3d(mapMarker3D); + mapMarker3DList.add(mapMarker3D); + } + private void addMapMarker3D(GeoCoordinates geoCoordinates) { // Place the files in the "assets" directory. // Full path example: app/src/main/assets/obstacle.obj diff --git a/examples/latest/navigate/android/MapItems/app/src/main/res/menu/map_option_menu.xml b/examples/latest/navigate/android/MapItems/app/src/main/res/menu/map_option_menu.xml index 274d223e..aa8d0a63 100644 --- a/examples/latest/navigate/android/MapItems/app/src/main/res/menu/map_option_menu.xml +++ b/examples/latest/navigate/android/MapItems/app/src/main/res/menu/map_option_menu.xml @@ -35,8 +35,10 @@ android:title="Location (NAV)"/> + + android:title="2D Texture"/> + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/Navigation/app/src/main/java/com/here/navigation/MainActivity.java b/examples/latest/navigate/android/Navigation/app/src/main/java/com/here/navigation/MainActivity.java index a597f3a5..5fc8f2be 100644 --- a/examples/latest/navigate/android/Navigation/app/src/main/java/com/here/navigation/MainActivity.java +++ b/examples/latest/navigate/android/Navigation/app/src/main/java/com/here/navigation/MainActivity.java @@ -171,19 +171,18 @@ public void clearMapButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); if (app != null) { app.detach(); } @@ -193,6 +192,9 @@ protected void onDestroy() { SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/NavigationCustom/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/NavigationCustom/app/src/main/AndroidManifest.xml index 3cda478f..2e676a3e 100644 --- a/examples/latest/navigate/android/NavigationCustom/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/NavigationCustom/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/NavigationCustom/app/src/main/java/com/here/navigationcustom/MainActivity.java b/examples/latest/navigate/android/NavigationCustom/app/src/main/java/com/here/navigationcustom/MainActivity.java index 13c5a899..cf90b003 100644 --- a/examples/latest/navigate/android/NavigationCustom/app/src/main/java/com/here/navigationcustom/MainActivity.java +++ b/examples/latest/navigate/android/NavigationCustom/app/src/main/java/com/here/navigationcustom/MainActivity.java @@ -398,19 +398,18 @@ private void startRouteSimulation(Route route) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); visualNavigator.stopRendering(); locationSimulator.stop(); mapView.onDestroy(); @@ -419,7 +418,10 @@ protected void onDestroy() { SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } private void showDialog(String title, String message) { diff --git a/examples/latest/navigate/android/NavigationQuickStart/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/NavigationQuickStart/app/src/main/AndroidManifest.xml index 67dd796a..a0ad6eb6 100644 --- a/examples/latest/navigate/android/NavigationQuickStart/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/NavigationQuickStart/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/NavigationQuickStart/app/src/main/java/com/here/navigationquickstart/MainActivity.java b/examples/latest/navigate/android/NavigationQuickStart/app/src/main/java/com/here/navigationquickstart/MainActivity.java index 670eb857..faf9f807 100644 --- a/examples/latest/navigate/android/NavigationQuickStart/app/src/main/java/com/here/navigationquickstart/MainActivity.java +++ b/examples/latest/navigate/android/NavigationQuickStart/app/src/main/java/com/here/navigationquickstart/MainActivity.java @@ -178,26 +178,28 @@ private void setupLocationSource(LocationListener locationListener, Route route) @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } private void showDialog(String title, String message) { diff --git a/examples/latest/navigate/android/OfflineMaps/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/OfflineMaps/app/src/main/AndroidManifest.xml index c731c139..df13b539 100644 --- a/examples/latest/navigate/android/OfflineMaps/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/OfflineMaps/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/OfflineMaps/app/src/main/java/com/here/offlinemaps/MainActivity.java b/examples/latest/navigate/android/OfflineMaps/app/src/main/java/com/here/offlinemaps/MainActivity.java index 9b97ef02..217a94f3 100644 --- a/examples/latest/navigate/android/OfflineMaps/app/src/main/java/com/here/offlinemaps/MainActivity.java +++ b/examples/latest/navigate/android/OfflineMaps/app/src/main/java/com/here/offlinemaps/MainActivity.java @@ -88,26 +88,28 @@ public void onLoadScene(@Nullable MapError mapError) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } public void onDownloadListClicked(View view) { diff --git a/examples/latest/navigate/android/Positioning/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/Positioning/app/src/main/AndroidManifest.xml index b2887c90..0454eea8 100644 --- a/examples/latest/navigate/android/Positioning/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/Positioning/app/src/main/AndroidManifest.xml @@ -23,7 +23,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/Positioning/app/src/main/java/com/here/examples/positioning/MainActivity.java b/examples/latest/navigate/android/Positioning/app/src/main/java/com/here/examples/positioning/MainActivity.java index 8ad18cb9..81b63671 100644 --- a/examples/latest/navigate/android/Positioning/app/src/main/java/com/here/examples/positioning/MainActivity.java +++ b/examples/latest/navigate/android/Positioning/app/src/main/java/com/here/examples/positioning/MainActivity.java @@ -129,19 +129,18 @@ public void onLoadScene(@Nullable MapError mapError) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); if (positioningExample != null) { positioningExample.stopLocating(); } @@ -151,7 +150,10 @@ protected void onDestroy() { SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } private void showDialog(String title, String message) { diff --git a/examples/latest/navigate/android/PublicTransit/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/PublicTransit/app/src/main/AndroidManifest.xml index 20c034f6..c5eef4e1 100644 --- a/examples/latest/navigate/android/PublicTransit/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/PublicTransit/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/PublicTransit/app/src/main/java/com/here/routing/MainActivity.java b/examples/latest/navigate/android/PublicTransit/app/src/main/java/com/here/routing/MainActivity.java index f9f2a79b..a8ee4635 100644 --- a/examples/latest/navigate/android/PublicTransit/app/src/main/java/com/here/routing/MainActivity.java +++ b/examples/latest/navigate/android/PublicTransit/app/src/main/java/com/here/routing/MainActivity.java @@ -96,25 +96,27 @@ public void clearMapButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/Routing/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/Routing/app/src/main/AndroidManifest.xml index 20c034f6..c5eef4e1 100644 --- a/examples/latest/navigate/android/Routing/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/Routing/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/Routing/app/src/main/java/com/here/routing/MainActivity.java b/examples/latest/navigate/android/Routing/app/src/main/java/com/here/routing/MainActivity.java index 682c46e5..036d5ec4 100644 --- a/examples/latest/navigate/android/Routing/app/src/main/java/com/here/routing/MainActivity.java +++ b/examples/latest/navigate/android/Routing/app/src/main/java/com/here/routing/MainActivity.java @@ -100,25 +100,27 @@ public void clearMapButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); - } + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); + } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/RoutingHybrid/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/RoutingHybrid/app/src/main/AndroidManifest.xml index de78c5e2..0edec743 100644 --- a/examples/latest/navigate/android/RoutingHybrid/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/RoutingHybrid/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/RoutingHybrid/app/src/main/java/com/here/routinghybrid/MainActivity.java b/examples/latest/navigate/android/RoutingHybrid/app/src/main/java/com/here/routinghybrid/MainActivity.java index 489292ec..2477bafe 100644 --- a/examples/latest/navigate/android/RoutingHybrid/app/src/main/java/com/here/routinghybrid/MainActivity.java +++ b/examples/latest/navigate/android/RoutingHybrid/app/src/main/java/com/here/routinghybrid/MainActivity.java @@ -108,25 +108,27 @@ public void switchOfflineButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/Search/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/Search/app/src/main/AndroidManifest.xml index e9f683af..98221588 100644 --- a/examples/latest/navigate/android/Search/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/Search/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/Search/app/src/main/java/com/here/search/MainActivity.java b/examples/latest/navigate/android/Search/app/src/main/java/com/here/search/MainActivity.java index 38e3acaf..189725b9 100644 --- a/examples/latest/navigate/android/Search/app/src/main/java/com/here/search/MainActivity.java +++ b/examples/latest/navigate/android/Search/app/src/main/java/com/here/search/MainActivity.java @@ -100,25 +100,27 @@ public void geocodeAnAddressButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/SearchHybrid/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/SearchHybrid/app/src/main/AndroidManifest.xml index e9f683af..98221588 100644 --- a/examples/latest/navigate/android/SearchHybrid/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/SearchHybrid/app/src/main/AndroidManifest.xml @@ -18,7 +18,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/SearchHybrid/app/src/main/java/com/here/search/MainActivity.java b/examples/latest/navigate/android/SearchHybrid/app/src/main/java/com/here/search/MainActivity.java index e8718538..69d67803 100644 --- a/examples/latest/navigate/android/SearchHybrid/app/src/main/java/com/here/search/MainActivity.java +++ b/examples/latest/navigate/android/SearchHybrid/app/src/main/java/com/here/search/MainActivity.java @@ -108,25 +108,27 @@ public void switchOfflineButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); - } + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); + } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/StandAloneEngine/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/StandAloneEngine/app/src/main/AndroidManifest.xml index 19083e82..a35f4c42 100644 --- a/examples/latest/navigate/android/StandAloneEngine/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/StandAloneEngine/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/StandAloneEngine/app/src/main/java/com/here/sdk/standaloneengine/MainActivity.java b/examples/latest/navigate/android/StandAloneEngine/app/src/main/java/com/here/sdk/standaloneengine/MainActivity.java index d81c2ee5..0266f6d4 100644 --- a/examples/latest/navigate/android/StandAloneEngine/app/src/main/java/com/here/sdk/standaloneengine/MainActivity.java +++ b/examples/latest/navigate/android/StandAloneEngine/app/src/main/java/com/here/sdk/standaloneengine/MainActivity.java @@ -101,12 +101,14 @@ public void onSearchCompleted(SearchError searchError, List list) { @Override protected void onDestroy() { - super.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/Traffic/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/Traffic/app/src/main/AndroidManifest.xml index 8c679ee1..7eb8811d 100644 --- a/examples/latest/navigate/android/Traffic/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/Traffic/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/Traffic/app/src/main/java/com/here/traffic/MainActivity.java b/examples/latest/navigate/android/Traffic/app/src/main/java/com/here/traffic/MainActivity.java index 73ff20f6..127059c2 100644 --- a/examples/latest/navigate/android/Traffic/app/src/main/java/com/here/traffic/MainActivity.java +++ b/examples/latest/navigate/android/Traffic/app/src/main/java/com/here/traffic/MainActivity.java @@ -98,25 +98,27 @@ public void disableAllButtonClicked(View view) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); - } + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); + } + super.onDestroy(); } } diff --git a/examples/latest/navigate/android/UnitTesting/app/src/main/AndroidManifest.xml b/examples/latest/navigate/android/UnitTesting/app/src/main/AndroidManifest.xml index af30eacc..3f669d9c 100644 --- a/examples/latest/navigate/android/UnitTesting/app/src/main/AndroidManifest.xml +++ b/examples/latest/navigate/android/UnitTesting/app/src/main/AndroidManifest.xml @@ -19,7 +19,8 @@ + android:exported="true" + android:configChanges="orientation|screenSize|screenLayout|keyboardHidden"> diff --git a/examples/latest/navigate/android/UnitTesting/app/src/main/java/com/here/hellomap/MainActivity.java b/examples/latest/navigate/android/UnitTesting/app/src/main/java/com/here/hellomap/MainActivity.java index 4fbc9f59..6187421f 100644 --- a/examples/latest/navigate/android/UnitTesting/app/src/main/java/com/here/hellomap/MainActivity.java +++ b/examples/latest/navigate/android/UnitTesting/app/src/main/java/com/here/hellomap/MainActivity.java @@ -98,25 +98,27 @@ public void onLoadScene(@Nullable MapError mapError) { @Override protected void onPause() { - super.onPause(); mapView.onPause(); + super.onPause(); } @Override protected void onResume() { - super.onResume(); mapView.onResume(); + super.onResume(); } @Override protected void onDestroy() { - super.onDestroy(); mapView.onDestroy(); // Free HERE SDK resources before the application shuts down. SDKNativeEngine hereSDKEngine = SDKNativeEngine.getSharedInstance(); if (hereSDKEngine != null) { hereSDKEngine.dispose(); + // For safety reasons, we explicitly set the shared instance to null to avoid situations, where a disposed instance is accidentally reused. + SDKNativeEngine.setSharedInstance(null); } + super.onDestroy(); } } diff --git a/examples/latest/navigate/flutter/custom_raster_layers_app/assets/poi.png b/examples/latest/navigate/flutter/custom_raster_layers_app/assets/poi.png new file mode 100644 index 00000000..9ce63731 Binary files /dev/null and b/examples/latest/navigate/flutter/custom_raster_layers_app/assets/poi.png differ diff --git a/examples/latest/navigate/flutter/custom_raster_layers_app/lib/CustomRasterLayersExample.dart b/examples/latest/navigate/flutter/custom_raster_layers_app/lib/CustomRasterLayersExample.dart index 4b7f9313..b7502eb0 100644 --- a/examples/latest/navigate/flutter/custom_raster_layers_app/lib/CustomRasterLayersExample.dart +++ b/examples/latest/navigate/flutter/custom_raster_layers_app/lib/CustomRasterLayersExample.dart @@ -17,6 +17,8 @@ * License-Filename: LICENSE */ +import 'dart:typed_data'; +import 'package:flutter/services.dart'; import 'package:here_sdk/core.dart'; import 'package:here_sdk/mapview.dart'; import 'package:here_sdk/mapview.datasource.dart'; @@ -25,6 +27,7 @@ class CustomRasterLayersExample { HereMapController _hereMapController; MapLayer? _rasterMapLayerTonerStyle; RasterDataSource? _rasterDataSourceTonerStyle; + MapImage? _poiMapImage; CustomRasterLayersExample(HereMapController this._hereMapController) { double distanceToEarthInMeters = 60000; @@ -37,6 +40,9 @@ class CustomRasterLayersExample { // We want to start with the default map style. _rasterMapLayerTonerStyle?.setEnabled(false); + + // Add a POI marker + _addPOIMapMarker(GeoCoordinates(52.530932, 13.384915), 1); } void enableButtonClicked() { @@ -59,6 +65,9 @@ class CustomRasterLayersExample { RasterDataSourceProviderConfiguration rasterProviderConfig = RasterDataSourceProviderConfiguration.withDefaults(templateUrl, TilingScheme.quadTreeMercator, storageLevels); + // If you want to add transparent layers then set this to true. + rasterProviderConfig.hasAlphaChannel = false; + // Raster tiles are stored in a separate cache on the device. String path = "cache/raster/toner"; int maxDiskSizeInBytes = 1024 * 1024 * 32; @@ -70,8 +79,8 @@ class CustomRasterLayersExample { } MapLayer _createMapLayer(String dataSourceName) { - // The layer should be rendered on top of other layers. - MapLayerPriority priority = MapLayerPriorityBuilder().renderedLast().build(); + // The layer should be rendered on top of other layers except the cartography layer consisting of the embedded Carto POI markers. + MapLayerPriority priority = MapLayerPriorityBuilder().renderedLast().renderedAfterLayer("ocm_cartography").build(); // And it should be visible for all zoom levels. MapLayerVisibilityRange range = MapLayerVisibilityRange(0, 22 + 1); @@ -94,4 +103,27 @@ class CustomRasterLayersExample { _rasterMapLayerTonerStyle?.destroy(); _rasterDataSourceTonerStyle?.destroy(); } + + Future _addPOIMapMarker(GeoCoordinates geoCoordinates, int drawOrder) async { + // Reuse existing MapImage for new map markers. + if (_poiMapImage == null) { + Uint8List imagePixelData = await _loadFileAsUint8List('assets/poi.png'); + _poiMapImage = MapImage.withPixelDataAndImageFormat(imagePixelData, ImageFormat.png); + } + + // By default, the anchor point is set to 0.5, 0.5 (= centered). + // Here the bottom, middle position should point to the location. + Anchor2D anchor2D = Anchor2D.withHorizontalAndVertical(0.5, 1); + + MapMarker mapMarker = MapMarker.withAnchor(geoCoordinates, _poiMapImage!, anchor2D); + mapMarker.drawOrder = drawOrder; + + _hereMapController.mapScene.addMapMarker(mapMarker); + } + + Future _loadFileAsUint8List(String assetPathToFile) async { + // The path refers to the assets directory as specified in pubspec.yaml. + ByteData fileData = await rootBundle.load(assetPathToFile); + return Uint8List.view(fileData.buffer); + } } diff --git a/examples/latest/navigate/flutter/custom_raster_layers_app/pubspec.yaml b/examples/latest/navigate/flutter/custom_raster_layers_app/pubspec.yaml index 86471971..73507c13 100644 --- a/examples/latest/navigate/flutter/custom_raster_layers_app/pubspec.yaml +++ b/examples/latest/navigate/flutter/custom_raster_layers_app/pubspec.yaml @@ -50,9 +50,8 @@ flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - # assets: - # - images/a_dot_burr.jpeg - # - images/a_dot_ham.jpeg + assets: + - assets/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware. diff --git a/examples/latest/navigate/flutter/ev_routing_app/lib/EVRoutingExample.dart b/examples/latest/navigate/flutter/ev_routing_app/lib/EVRoutingExample.dart index 4dafa4f3..6ae77a39 100644 --- a/examples/latest/navigate/flutter/ev_routing_app/lib/EVRoutingExample.dart +++ b/examples/latest/navigate/flutter/ev_routing_app/lib/EVRoutingExample.dart @@ -102,12 +102,18 @@ class EVRoutingExample { evCarOptions.consumptionModel.descentRecoveryInWattHoursPerMeter = 4.3; evCarOptions.consumptionModel.freeFlowSpeedTable = {0: 0.239, 27: 0.239, 60: 0.196, 90: 0.238}; - // Ensure that the vehicle does not run out of energy along the way and charging stations are added as additional waypoints. + // Must be 0 for isoline calculation. + evCarOptions.routeOptions.alternatives = 0; + + // Ensure that the vehicle does not run out of energy along the way + // and charging stations are added as additional waypoints. evCarOptions.ensureReachability = true; - // The below options are required when setting the ensureReachability option to true. + // The below options are required when setting the ensureReachability option to true + // (AvoidanceOptions need to be empty). + evCarOptions.avoidanceOptions = AvoidanceOptions.withDefaults(); + evCarOptions.routeOptions.speedCapInMetersPerSecond = null; evCarOptions.routeOptions.optimizationMode = OptimizationMode.fastest; - evCarOptions.routeOptions.alternatives = 0; evCarOptions.batterySpecifications.connectorTypes = [ ChargingConnectorType.tesla, ChargingConnectorType.iec62196Type1Combo, diff --git a/examples/latest/navigate/flutter/indoor_map_app/lib/main.dart b/examples/latest/navigate/flutter/indoor_map_app/lib/main.dart index dc029ebb..5271cc8b 100644 --- a/examples/latest/navigate/flutter/indoor_map_app/lib/main.dart +++ b/examples/latest/navigate/flutter/indoor_map_app/lib/main.dart @@ -18,6 +18,7 @@ */ import 'package:flutter/material.dart'; +import 'package:here_sdk/core.errors.dart'; import 'package:indoor_map_app/geometry_info.dart'; import 'package:indoor_map_app/settings_page.dart'; import 'package:indoor_map_app/venue_engine_widget.dart'; @@ -134,8 +135,13 @@ class MainPage extends StatelessWidget { hereMapController.mapScene.setLayerVisibility(MapSceneLayers.extrudedBuildings, VisibilityState.hidden); // Create a venue engine object. Once the initialization is done, // a callback will be called. - var venueEngine = VenueEngine(_onVenueEngineCreated); - _venueEngineState.set(hereMapController, venueEngine, _geometryInfoState); + var venueEngine; + try { + venueEngine = VenueEngine(_onVenueEngineCreated); + _venueEngineState.set(hereMapController, venueEngine, _geometryInfoState); + } on InstantiationException catch(e){ + print('error caught: $e'); + } }); } diff --git a/examples/latest/navigate/flutter/map_items_app/lib/MapItemsExample.dart b/examples/latest/navigate/flutter/map_items_app/lib/MapItemsExample.dart index 60dfe24e..300c02ec 100644 --- a/examples/latest/navigate/flutter/map_items_app/lib/MapItemsExample.dart +++ b/examples/latest/navigate/flutter/map_items_app/lib/MapItemsExample.dart @@ -17,6 +17,7 @@ * License-Filename: LICENSE */ +import 'dart:io'; import 'dart:math'; import 'dart:typed_data'; @@ -127,14 +128,28 @@ class MapItemsExample { _addLocationIndicator(geoCoordinates, LocationIndicatorIndicatorStyle.navigation); } - void showFlatMapMarkers() { + void showFlatMapMarker() { + // Tilt the map for a better 3D effect. + _tiltMap(); + + GeoCoordinates geoCoordinates = _createRandomGeoCoordinatesAroundMapCenter(); + + // It's origin is centered on the location. + _addFlatMarker(geoCoordinates); + + // A centered 2D map marker to indicate the exact location. + // Note that 3D map markers are always drawn on top of 2D map markers. + _addCircleMapMarker(geoCoordinates, 1); + } + + void show2DTexture() { // Tilt the map for a better 3D effect. _tiltMap(); GeoCoordinates geoCoordinates = _createRandomGeoCoordinatesAroundMapCenter(); // Adds a flat POI marker that rotates and tilts together with the map. - _addFlatMarker3D(geoCoordinates); + _add2DTexture(geoCoordinates); // A centered 2D map marker to indicate the exact location. // Note that 3D map markers are always drawn on top of 2D map markers. @@ -243,7 +258,23 @@ class MapItemsExample { _locationIndicatorList.add(locationIndicator); } - void _addFlatMarker3D(GeoCoordinates geoCoordinates) { + void _addFlatMarker(GeoCoordinates geoCoordinates) async { + + Uint8List imagePixelData = await _loadFileAsUint8List('assets/poi.png'); + MapImage mapImage = MapImage.withPixelDataAndImageFormat(imagePixelData, ImageFormat.png); + + // The default scale factor of the map marker is 1.0. For a scale of 2, the map marker becomes 2x larger. + // For a scale of 0.5, the map marker shrinks to half of its original size. + double scaleFactor = 0.5; + + // With DENSITY_INDEPENDENT_PIXELS the map marker will have a constant size on the screen regardless if the map is zoomed in or out. + MapMarker3D mapMarker3D = MapMarker3D.fromImage(geoCoordinates,mapImage, scaleFactor, RenderSizeUnit.densityIndependentPixels); + + _hereMapController.mapScene.addMapMarker3d(mapMarker3D); + _mapMarker3DList.add(mapMarker3D); + } + + void _add2DTexture(GeoCoordinates geoCoordinates) { // Place the files in the "assets" directory as specified in pubspec.yaml. // Adjust file name and path as appropriate for your project. // Note: The bottom of the plane is centered on the origin. diff --git a/examples/latest/navigate/flutter/map_items_app/lib/main.dart b/examples/latest/navigate/flutter/map_items_app/lib/main.dart index 4ac2c080..99ff2ab9 100644 --- a/examples/latest/navigate/flutter/map_items_app/lib/main.dart +++ b/examples/latest/navigate/flutter/map_items_app/lib/main.dart @@ -97,7 +97,11 @@ class _MyAppState extends State { } void _flatMapMarkersButtonClicked() { - _mapItemsExample?.showFlatMapMarkers(); + _mapItemsExample?.showFlatMapMarker(); + } + + void _2DTextureButtonClicked() { + _mapItemsExample?.show2DTexture(); } void _mapMarkers3DButtonClicked() { @@ -185,7 +189,8 @@ class _MyAppState extends State { MenuSectionItem("Anchored (2D)", _anchoredMapMarkersButtonClicked), MenuSectionItem("Centered (2D)", _centeredMapMarkersButtonClicked), MenuSectionItem("MapMarkerCluster", _mapMarkerClusterButtonClicked), - MenuSectionItem("Flat", _flatMapMarkersButtonClicked), + MenuSectionItem("Flat MapMarker", _flatMapMarkersButtonClicked), + MenuSectionItem("2DTexture", _2DTextureButtonClicked), MenuSectionItem("3D OBJ", _mapMarkers3DButtonClicked), ]; diff --git a/examples/latest/navigate/flutter/positioning_app/ios/Runner/Info.plist b/examples/latest/navigate/flutter/positioning_app/ios/Runner/Info.plist index d685db1c..b7314e8b 100644 --- a/examples/latest/navigate/flutter/positioning_app/ios/Runner/Info.plist +++ b/examples/latest/navigate/flutter/positioning_app/ios/Runner/Info.plist @@ -38,6 +38,11 @@ UIBackgroundModes location + processing + + BGTaskSchedulerPermittedIdentifiers + + $(PRODUCT_BUNDLE_IDENTIFIER) UILaunchStoryboardName LaunchScreen diff --git a/examples/latest/navigate/flutter/positioning_app/lib/PositioningExample.dart b/examples/latest/navigate/flutter/positioning_app/lib/PositioningExample.dart index c16d6393..e8b69ff1 100644 --- a/examples/latest/navigate/flutter/positioning_app/lib/PositioningExample.dart +++ b/examples/latest/navigate/flutter/positioning_app/lib/PositioningExample.dart @@ -262,7 +262,12 @@ class PositioningExample extends State } _addMyLocationToMap(location); - + + // Enable background updates on iOS. + _locationEngine.setBackgroundLocationAllowed(true); + _locationEngine.setBackgroundLocationIndicatorVisible(true); + + // Set delegates and start location engine. _locationEngine.addLocationListener(this); _locationEngine.addLocationStatusListener(this); _locationEngine.startWithLocationAccuracy(LocationAccuracy.bestAvailable); @@ -276,7 +281,7 @@ class PositioningExample extends State void _addMyLocationToMap(Location myLocation) { if (_locationIndicator != null) { - _hereMapController?.removeLifecycleListener(_locationIndicator!); + return; } // Set-up location indicator. _locationIndicator = LocationIndicator(); diff --git a/examples/latest/navigate/ios/Camera/README.md b/examples/latest/navigate/ios/Camera/README.md index a4731a60..3d461098 100644 --- a/examples/latest/navigate/ios/Camera/README.md +++ b/examples/latest/navigate/ios/Camera/README.md @@ -3,7 +3,7 @@ The Canera example app shows how to change the target anchor point and how to mo Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/CameraKeyframeTracks/README.md b/examples/latest/navigate/ios/CameraKeyframeTracks/README.md index a723af6c..a27df383 100644 --- a/examples/latest/navigate/ios/CameraKeyframeTracks/README.md +++ b/examples/latest/navigate/ios/CameraKeyframeTracks/README.md @@ -3,7 +3,7 @@ The CameraKeyframeTracks example app shows how to use multiple keyframe tracks f Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/CartoPOIPicking/README.md b/examples/latest/navigate/ios/CartoPOIPicking/README.md index 807ad1a7..f7cb01dd 100644 --- a/examples/latest/navigate/ios/CartoPOIPicking/README.md +++ b/examples/latest/navigate/ios/CartoPOIPicking/README.md @@ -3,7 +3,7 @@ The CartoPOIPicking example app shows how the HERE SDK can be used to pick embed Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/CustomMapStylesNavigate/README.md b/examples/latest/navigate/ios/CustomMapStylesNavigate/README.md index 3b26c8b5..3d3249ce 100644 --- a/examples/latest/navigate/ios/CustomMapStylesNavigate/README.md +++ b/examples/latest/navigate/ios/CustomMapStylesNavigate/README.md @@ -3,7 +3,7 @@ This example app shows how to load custom maps. You can find how this is done in Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/Contents.json b/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/Contents.json new file mode 100644 index 00000000..1d8ce251 --- /dev/null +++ b/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "poi@1x.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "poi@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "poi@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} \ No newline at end of file diff --git a/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@1x.png b/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@1x.png new file mode 100644 index 00000000..c288ce06 Binary files /dev/null and b/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@1x.png differ diff --git a/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@2x.png b/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@2x.png new file mode 100644 index 00000000..9ce63731 Binary files /dev/null and b/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@2x.png differ diff --git a/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@3x.png b/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@3x.png new file mode 100644 index 00000000..63841c53 Binary files /dev/null and b/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/Assets.xcassets/poi.imageset/poi@3x.png differ diff --git a/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/CustomRasterLayersExample.swift b/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/CustomRasterLayersExample.swift index 961117d2..98ebe467 100644 --- a/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/CustomRasterLayersExample.swift +++ b/examples/latest/navigate/ios/CustomRasterLayers/CustomRasterLayers/CustomRasterLayersExample.swift @@ -42,6 +42,9 @@ class CustomRasterLayersExample { // We want to start with the default map style. rasterMapLayerTonerStyle.setEnabled(false) + + // Add a POI marker + addPOIMapMarker(geoCoordinates: GeoCoordinates(latitude: 52.530932, longitude: 13.384915)) } func onEnableButtonClicked() { @@ -61,10 +64,13 @@ class CustomRasterLayersExample { let templateUrl = "https://stamen-tiles.a.ssl.fastly.net/toner/{z}/{x}/{y}.png" // The storage levels available for this data source. Supported range [0, 31]. let storageLevels: [Int32] = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16] - let rasterProviderConfig = RasterDataSourceConfiguration.Provider(templateUrl: templateUrl, + var rasterProviderConfig = RasterDataSourceConfiguration.Provider(templateUrl: templateUrl, tilingScheme: TilingScheme.quadTreeMercator, storageLevels: storageLevels) + // If you want to add transparent layers then set this to true. + rasterProviderConfig.hasAlphaChannel = false + // Raster tiles are stored in a separate cache on the device. let path = "cache/raster/toner" let maxDiskSizeInBytes: Int64 = 1024 * 1024 * 32 @@ -79,8 +85,8 @@ class CustomRasterLayersExample { } private func createMapLayer(dataSourceName: String) -> MapLayer { - // The layer should be rendered on top of other layers. - let priority = MapLayerPriorityBuilder().renderedLast().build() + // The layer should be rendered on top of other layers except the cartography layer consisting of the embedded Carto POI markers. + let priority = MapLayerPriorityBuilder().renderedLast().renderedAfterLayer(named: "ocm_cartography").build() // And it should be visible for all zoom levels. let range = MapLayerVisibilityRange(minimumZoomLevel: 0, maximumZoomLevel: 22 + 1) @@ -101,4 +107,23 @@ class CustomRasterLayersExample { fatalError("MapLayer creation failed Cause: \(InstantiationException)") } } + + private func addPOIMapMarker(geoCoordinates: GeoCoordinates) { + guard + let image = UIImage(named: "poi.png"), + let imageData = image.pngData() else { + print("Error: Image not found.") + return + } + + // The bottom, middle position should point to the location. + // By default, the anchor point is set to 0.5, 0.5. + let anchorPoint = Anchor2D(horizontal: 0.5, vertical: 1) + let mapMarker = MapMarker(at: geoCoordinates, + image: MapImage(pixelData: imageData, + imageFormat: ImageFormat.png), + anchor: anchorPoint) + + mapView.mapScene.addMapMarker(mapMarker) + } } diff --git a/examples/latest/navigate/ios/CustomRasterLayers/README.md b/examples/latest/navigate/ios/CustomRasterLayers/README.md index a9ae84fa..a2ead035 100644 --- a/examples/latest/navigate/ios/CustomRasterLayers/README.md +++ b/examples/latest/navigate/ios/CustomRasterLayers/README.md @@ -3,7 +3,7 @@ This example app shows how to load custom raster layers. You can find how this i Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/CustomRasterLayers/assets/poi_texture.png b/examples/latest/navigate/ios/CustomRasterLayers/assets/poi_texture.png new file mode 100644 index 00000000..40a543ae Binary files /dev/null and b/examples/latest/navigate/ios/CustomRasterLayers/assets/poi_texture.png differ diff --git a/examples/latest/navigate/ios/EVRouting/EVRouting/RoutingExample.swift b/examples/latest/navigate/ios/EVRouting/EVRouting/RoutingExample.swift index 52c0afd7..15f48875 100644 --- a/examples/latest/navigate/ios/EVRouting/EVRouting/RoutingExample.swift +++ b/examples/latest/navigate/ios/EVRouting/EVRouting/RoutingExample.swift @@ -95,12 +95,18 @@ class RoutingExample { 60: 0.196, 90: 0.238] - // Ensure that the vehicle does not run out of energy along the way and charging stations are added as additional waypoints. + // Must be 0 for isoline calculation. + evCarOptions.routeOptions.alternatives = 0 + + // Ensure that the vehicle does not run out of energy along the way + // and charging stations are added as additional waypoints. evCarOptions.ensureReachability = true - // The below options are required when setting the ensureReachability option to true. + // The below options are required when setting the ensureReachability option to true + // (AvoidanceOptions need to be empty). + evCarOptions.avoidanceOptions = AvoidanceOptions() + evCarOptions.routeOptions.speedCapInMetersPerSecond = nil evCarOptions.routeOptions.optimizationMode = .fastest - evCarOptions.routeOptions.alternatives = 0 evCarOptions.batterySpecifications.connectorTypes = [.tesla, .iec62196Type1Combo, .iec62196Type2Combo] evCarOptions.batterySpecifications.totalCapacityInKilowattHours = 80.0 evCarOptions.batterySpecifications.initialChargeInKilowattHours = 10.0 diff --git a/examples/latest/navigate/ios/EVRouting/README.md b/examples/latest/navigate/ios/EVRouting/README.md index 643d24b9..1c7ba539 100644 --- a/examples/latest/navigate/ios/EVRouting/README.md +++ b/examples/latest/navigate/ios/EVRouting/README.md @@ -3,7 +3,7 @@ The EVRouting example app shows how the HERE SDK can be used to calculate routes Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/Gestures/README.md b/examples/latest/navigate/ios/Gestures/README.md index b8f01f21..d8410aee 100644 --- a/examples/latest/navigate/ios/Gestures/README.md +++ b/examples/latest/navigate/ios/Gestures/README.md @@ -3,7 +3,7 @@ The Gesture example app shows how to handle common map interactions and gestures Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/HelloMap/README.md b/examples/latest/navigate/ios/HelloMap/README.md index 079d8a35..206a6017 100644 --- a/examples/latest/navigate/ios/HelloMap/README.md +++ b/examples/latest/navigate/ios/HelloMap/README.md @@ -3,7 +3,7 @@ The HelloMap example app shows how the HERE SDK can be integrated into your proj Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/HelloMapCarPlay/README.md b/examples/latest/navigate/ios/HelloMapCarPlay/README.md index 64852d5a..665d5c24 100644 --- a/examples/latest/navigate/ios/HelloMapCarPlay/README.md +++ b/examples/latest/navigate/ios/HelloMapCarPlay/README.md @@ -3,9 +3,9 @@ The HelloMapCarPlay example app shows how [CarPlay](https://www.apple.com/de/ios Build instructions: ------------------- -1) Edit `HelloMapCarPlay/HelloMapCarPlay/Entitlements.plist` to uncomment the key for testing purposes. For a production-ready app, [contact Apple](https://developer.apple.com/documentation/carplay/requesting_carplay_entitlements) to include the required entitlements in your provisioning profile for signing the app. Until then, this app cannot be tested on a real device. Use an iOS simulator instead. From the simulator menu bar, choose _I/O -> External Displays -> CarPlay_ to show the CarPlay head unit simulator on your development machine. +1) Edit `HelloMapCarPlay/HelloMapCarPlay/Entitlements.plist` to uncomment the key for testing purposes. For a production-ready app, [contact Apple](https://developer.apple.com/documentation/carplay/requesting_carplay_entitlements) to include the required entitlements in your provisioning profile for signing the app. Until then, this app cannot be tested on a real device. Use an iOS simulator instead (>= min supported iOS version of HERE SDK). From the simulator menu bar, choose _I/O -> External Displays -> CarPlay_ to show the CarPlay head unit simulator on your development machine. -2) Copy the `heresdk.xcframework` file to your app's root folder. +2) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/HelloMapWithStoryboard/README.md b/examples/latest/navigate/ios/HelloMapWithStoryboard/README.md index ec777dc0..5cf6238c 100644 --- a/examples/latest/navigate/ios/HelloMapWithStoryboard/README.md +++ b/examples/latest/navigate/ios/HelloMapWithStoryboard/README.md @@ -3,7 +3,7 @@ The HelloMapWithStoryboard example app shows how to build your UI from Xcode’s Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/IndoorMap/IndoorMap/ViewController.swift b/examples/latest/navigate/ios/IndoorMap/IndoorMap/ViewController.swift index f37b24bd..8373c141 100644 --- a/examples/latest/navigate/ios/IndoorMap/IndoorMap/ViewController.swift +++ b/examples/latest/navigate/ios/IndoorMap/IndoorMap/ViewController.swift @@ -80,7 +80,12 @@ class ViewController: UIViewController { // Create a venue engine object. Once the initialization is done, a completion handler // will be called. - venueEngine = VenueEngine { [weak self] in self?.onVenueEngineInit() } + do { + try venueEngine = VenueEngine { [weak self] in self?.onVenueEngineInit() } + } catch { + print("SDK Engine not instantiated: \(error)") + } + } private func onVenueEngineInit() { diff --git a/examples/latest/navigate/ios/IndoorMap/README.md b/examples/latest/navigate/ios/IndoorMap/README.md index 8106a71b..362665df 100644 --- a/examples/latest/navigate/ios/IndoorMap/README.md +++ b/examples/latest/navigate/ios/IndoorMap/README.md @@ -3,7 +3,7 @@ The Indoor Map example app shows how to display private venues on a map view and Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. @@ -12,6 +12,6 @@ Note: If your framework version is different than the version shown in the _Deve Note: In Xcode, open the _General_ settings of the _App target_ and make sure that the HERE SDK framework appears under _Embedded Binaries_. If it does not appear, add the `heresdk.framework` to the _Embedded Binaries_ section ("Add other..." -> "Create folder references"). Please do not forget: To run the app, you need to follow the below mentioned steps. More information can be found in the _Get Started_ section of the _Developer's Guide_. -1) Add your HERE SDK credentials to the `Info.plist` file. +1) Add your HERE SDK credentials to the `Info.plist` file. 2) Set the value of your indoor map catalog HRN to the constant `let hrn: String` in the `/IndoorMap/ViewController.swift` file. -3) Enter your indoor map id once the app loads. \ No newline at end of file +3) Enter your indoor map id once the app loads. diff --git a/examples/latest/navigate/ios/MapItems/MapItems/MapItemsExample.swift b/examples/latest/navigate/ios/MapItems/MapItems/MapItemsExample.swift index 80ffd9a9..379da062 100644 --- a/examples/latest/navigate/ios/MapItems/MapItems/MapItemsExample.swift +++ b/examples/latest/navigate/ios/MapItems/MapItems/MapItemsExample.swift @@ -130,8 +130,22 @@ class MapItemsExample: TapDelegate { let geoCoordinates = createRandomGeoCoordinatesAroundMapCenter() + // It's origin is centered on the location. + addFlatMarker(geoCoordinates: geoCoordinates) + + // A centered 2D map marker to indicate the exact location. + // Note that 3D map markers are always drawn on top of 2D map markers. + addCircleMapMarker(geoCoordinates: geoCoordinates) + } + + public func on2DTextureButtonClicked() { + // Tilt the map for a better 3D effect. + tiltMap() + + let geoCoordinates = createRandomGeoCoordinatesAroundMapCenter() + // Adds a flat POI marker that rotates and tilts together with the map. - addFlatMarker3D(geoCoordinates: geoCoordinates) + add2DTexture(geoCoordinates: geoCoordinates) // A centered 2D map marker to indicate the exact location. // Note that 3D map markers are always drawn on top of 2D map markers. @@ -208,11 +222,11 @@ class MapItemsExample: TapDelegate { let mapMarker = MapMarker(at: geoCoordinates, image: MapImage(pixelData: imageData, imageFormat: ImageFormat.png)) - + // Optionally, enable a fade in-out animation. let durationInSeconds: TimeInterval = 3 mapMarker.fadeDuration = durationInSeconds - + mapView.mapScene.addMapMarker(mapMarker) mapMarkers.append(mapMarker) } @@ -245,7 +259,7 @@ class MapItemsExample: TapDelegate { } } - private func addFlatMarker3D(geoCoordinates: GeoCoordinates) { + private func add2DTexture(geoCoordinates: GeoCoordinates) { // Place the files to an "assets" directory via drag & drop. // Adjust file name and path as appropriate for your project. // Note: The bottom of the plane is centered on the origin. @@ -263,6 +277,27 @@ class MapItemsExample: TapDelegate { mapMarkers3D.append(mapMarker3D) } + private func addFlatMarker(geoCoordinates: GeoCoordinates) { + guard + let image = UIImage(named: "poi.png"), + let imageData = image.pngData() else { + print("Error: Image not found.") + return + } + + // The default scale factor of the map marker is 1.0. For a scale of 2, the map marker becomes 2x larger. + // For a scale of 0.5, the map marker shrinks to half of its original size. + let scaleFactor: Double = 0.5 + + let mapImage:MapImage = MapImage(pixelData: imageData, imageFormat: ImageFormat.png) + + // With DENSITY_INDEPENDENT_PIXELS the map marker will have a constant size on the screen regardless if the map is zoomed in or out. + let mapMarker3D: MapMarker3D = MapMarker3D(at: geoCoordinates, image: mapImage, scale: scaleFactor, unit: RenderSize.Unit.densityIndependentPixels) + + mapView.mapScene.addMapMarker3d(mapMarker3D) + mapMarkers3D.append(mapMarker3D) + } + private func addMapMarker3D(geoCoordinates: GeoCoordinates) { // Place the files to an "assets" directory via drag & drop. // Adjust file name and path as appropriate for your project. @@ -271,16 +306,16 @@ class MapItemsExample: TapDelegate { // Without depth check, 3D models are rendered on top of everything. With depth check enabled, // it may be hidden by buildings. In addition: - // If a 3D object has its center at the origin of its internal coordinate system, + // If a 3D object has its center at the origin of its internal coordinate system, // then parts of it may be rendered below the ground surface (altitude < 0). - // Note that the HERE SDK map surface is flat, following a Mercator or Globe projection. + // Note that the HERE SDK map surface is flat, following a Mercator or Globe projection. // Therefore, a 3D object becomes visible when the altitude of its location is 0 or higher. // By default, without setting a scale factor, 1 unit in 3D coordinate space equals 1 meter. - let geoCoordinatesWithAltitude = GeoCoordinates(latitude: geoCoordinates.latitude, - longitude: geoCoordinates.longitude, - altitude: 18.0) + let geoCoordinatesWithAltitude = GeoCoordinates(latitude: geoCoordinates.latitude, + longitude: geoCoordinates.longitude, + altitude: 18.0) let mapMarker3DModel = MapMarker3DModel(geometryFilePath: geometryFile, textureFilePath: textureFile) - let mapMarker3D = MapMarker3D(at: geoCoordinatesWithAltitude, model: mapMarker3DModel) + let mapMarker3D = MapMarker3D(at: geoCoordinatesWithAltitude, model: mapMarker3DModel) mapMarker3D.scale = 6 mapMarker3D.isDepthCheckEnabled = true @@ -330,12 +365,12 @@ class MapItemsExample: TapDelegate { if let groupingList = pickedMapItems?.clusteredMarkers { handlePickedMapMarkerClusters(groupingList) } - + // Note that 3D map markers can't be picked yet. Only marker, polgon and polyline map items are pickable. guard let topmostMapMarker = pickedMapItems?.markers.first else { return } - + if let message = topmostMapMarker.metadata?.getString(key: "key_poi") { showDialog(title: "Map Marker picked", message: message) return @@ -348,7 +383,7 @@ class MapItemsExample: TapDelegate { guard let topmostGrouping = groupingList.first else { return } - + let clusterSize = topmostGrouping.markers.count if (clusterSize == 0) { // This cluster does not contain any MapMarker items. @@ -361,7 +396,7 @@ class MapItemsExample: TapDelegate { message: "Number of contained markers in this cluster: \(clusterSize). Total number of markers in this MapMarkerCluster: \(topmostGrouping.parent.markers.count)") } } - + private func createRandomGeoCoordinatesAroundMapCenter() -> GeoCoordinates { let scaleFactor = UIScreen.main.scale let mapViewWidthInPixels = Double(mapView.bounds.width * scaleFactor) diff --git a/examples/latest/navigate/ios/MapItems/MapItems/ViewController.swift b/examples/latest/navigate/ios/MapItems/MapItems/ViewController.swift index 98f7eaa7..ac2986d0 100644 --- a/examples/latest/navigate/ios/MapItems/MapItems/ViewController.swift +++ b/examples/latest/navigate/ios/MapItems/MapItems/ViewController.swift @@ -50,7 +50,7 @@ final class ViewController: UIViewController { mapViewPinsExample = MapViewPinsExample(mapView: mapView) isMapSceneLoaded = true } - + override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() mapView.handleLowMemory() @@ -67,49 +67,55 @@ final class ViewController: UIViewController { @IBAction func onMenuButtonClicked(_ sender: UIBarButtonItem) { performSegue(withIdentifier: "showMenu", sender: nil) } - + private func onAnchoredButtonClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onAnchoredButtonClicked() } } - + private func onCenteredButtonClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onCenteredButtonClicked() } } - + private func onMapMarkerClusterButtonClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onMapMarkerClusterButtonClicked() } } - + private func onLocationIndicatorPedestrianButtonClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onLocationIndicatorPedestrianButtonClicked() } } - + private func onLocationIndicatorNavigationButtonClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onLocationIndicatorNavigationButtonClicked() } } - + private func onLocationIndicatorStateClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.toggleActiveStateForLocationIndicator() } } - + private func onFlatMapMarkerButtonClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onFlatMapMarkerButtonClicked() } } + private func on2DTextureButtonClicked(_ sender: Any) { + if isMapSceneLoaded { + mapItemsExample.on2DTextureButtonClicked() + } + } + private func onMapMarker3DClicked(_ sender: Any) { if isMapSceneLoaded { mapItemsExample.onMapMarker3DClicked() @@ -176,7 +182,8 @@ final class ViewController: UIViewController { MenuItem(title: "Anchored (2D)", onSelect: onAnchoredButtonClicked), MenuItem(title: "Centered (2D)", onSelect: onCenteredButtonClicked), MenuItem(title: "MapMarkerCluster", onSelect: onMapMarkerClusterButtonClicked), - MenuItem(title: "Flat", onSelect: onFlatMapMarkerButtonClicked), + MenuItem(title: "Flat Marker", onSelect: onFlatMapMarkerButtonClicked), + MenuItem(title: "2D Texture", onSelect: on2DTextureButtonClicked), MenuItem(title: "3D Marker", onSelect: onMapMarker3DClicked) ]) } diff --git a/examples/latest/navigate/ios/MapItems/README.md b/examples/latest/navigate/ios/MapItems/README.md index 33462b90..798b1d78 100644 --- a/examples/latest/navigate/ios/MapItems/README.md +++ b/examples/latest/navigate/ios/MapItems/README.md @@ -3,7 +3,7 @@ The MapItems example app shows how to pin images and 3D objects to mark specific Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/Navigation/README.md b/examples/latest/navigate/ios/Navigation/README.md index 4783a4ca..768a96d0 100644 --- a/examples/latest/navigate/ios/Navigation/README.md +++ b/examples/latest/navigate/ios/Navigation/README.md @@ -3,7 +3,7 @@ The Navigation example app shows how to calculate a route from A to B and how to Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/NavigationCustom/README.md b/examples/latest/navigate/ios/NavigationCustom/README.md index 8b00c0a3..13a3c40f 100644 --- a/examples/latest/navigate/ios/NavigationCustom/README.md +++ b/examples/latest/navigate/ios/NavigationCustom/README.md @@ -4,7 +4,7 @@ assets. On top, the app shows how to customize the guidance view by setting cust Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/NavigationQuickStart/README.md b/examples/latest/navigate/ios/NavigationQuickStart/README.md index f1c546d3..06b224fa 100644 --- a/examples/latest/navigate/ios/NavigationQuickStart/README.md +++ b/examples/latest/navigate/ios/NavigationQuickStart/README.md @@ -3,7 +3,7 @@ The Navigation Quick Start example app shows how the HERE SDK can be set up to n Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/OfflineMaps/README.md b/examples/latest/navigate/ios/OfflineMaps/README.md index 69f3e42f..fb530bb8 100644 --- a/examples/latest/navigate/ios/OfflineMaps/README.md +++ b/examples/latest/navigate/ios/OfflineMaps/README.md @@ -3,7 +3,7 @@ The OfflineMaps example app shows how the HERE SDK can work fully offline and ho Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/Positioning/Positioning/Info.plist b/examples/latest/navigate/ios/Positioning/Positioning/Info.plist index 95a6adc9..a8d82928 100644 --- a/examples/latest/navigate/ios/Positioning/Positioning/Info.plist +++ b/examples/latest/navigate/ios/Positioning/Positioning/Info.plist @@ -36,6 +36,11 @@ UIBackgroundModes location + processing + + BGTaskSchedulerPermittedIdentifiers + + $(PRODUCT_BUNDLE_IDENTIFIER) UILaunchStoryboardName LaunchScreen diff --git a/examples/latest/navigate/ios/Positioning/Positioning/PositioningExample.swift b/examples/latest/navigate/ios/Positioning/Positioning/PositioningExample.swift index 6999c40a..681b9620 100644 --- a/examples/latest/navigate/ios/Positioning/Positioning/PositioningExample.swift +++ b/examples/latest/navigate/ios/Positioning/Positioning/PositioningExample.swift @@ -66,6 +66,10 @@ class PositioningExample: LocationDelegate, LocationStatusDelegate, LocationAuth } private func startLocating() { + // Enable background updates. + locationEngine.setBackgroundLocationAllowed(allowed: true) + locationEngine.setBackgroundLocationIndicatorVisible(visible: true) + // Set delegates and start location engine. locationEngine.addLocationStatusDelegate(locationStatusDelegate: self) locationEngine.addLocationDelegate(locationDelegate: self) diff --git a/examples/latest/navigate/ios/Positioning/README.md b/examples/latest/navigate/ios/Positioning/README.md index 633e755c..f480b811 100644 --- a/examples/latest/navigate/ios/Positioning/README.md +++ b/examples/latest/navigate/ios/Positioning/README.md @@ -3,6 +3,6 @@ The Positioning example app shows how to use the location engine to visualize yo Build instructions: ------------------- -1) Copy the heresdk.framework file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. 2) In Xcode, open the General settings of the App target and make sure that the HERE SDK framework appears under Embedded Binaries. If it does not appear, add the heresdk.framework to the Embedded Binaries section ("Add other..." -> "Create folder references"). diff --git a/examples/latest/navigate/ios/PublicTransit/README.md b/examples/latest/navigate/ios/PublicTransit/README.md index 7a52afb7..5b5b57fd 100644 --- a/examples/latest/navigate/ios/PublicTransit/README.md +++ b/examples/latest/navigate/ios/PublicTransit/README.md @@ -3,7 +3,7 @@ The Public Transit example app shows how to calculate a public transport route f Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/Routing/README.md b/examples/latest/navigate/ios/Routing/README.md index ba372532..83ce031f 100644 --- a/examples/latest/navigate/ios/Routing/README.md +++ b/examples/latest/navigate/ios/Routing/README.md @@ -3,7 +3,7 @@ The Routing example app shows how to calculate a route from A to B with a number Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/RoutingHybrid/README.md b/examples/latest/navigate/ios/RoutingHybrid/README.md index c665d88d..69761a79 100644 --- a/examples/latest/navigate/ios/RoutingHybrid/README.md +++ b/examples/latest/navigate/ios/RoutingHybrid/README.md @@ -3,7 +3,7 @@ The Routing example app shows how to calculate a route from A to B with a number Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/Search/README.md b/examples/latest/navigate/ios/Search/README.md index 9ff30cd9..7b7aee06 100644 --- a/examples/latest/navigate/ios/Search/README.md +++ b/examples/latest/navigate/ios/Search/README.md @@ -3,7 +3,7 @@ The Search example app shows how to search for places including auto suggestions Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/SearchHybrid/README.md b/examples/latest/navigate/ios/SearchHybrid/README.md index e4c6e4b4..817d605e 100644 --- a/examples/latest/navigate/ios/SearchHybrid/README.md +++ b/examples/latest/navigate/ios/SearchHybrid/README.md @@ -3,7 +3,7 @@ The SearchHybrid example app shows how to search for places including auto sugge Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/StandAloneEngine/README.md b/examples/latest/navigate/ios/StandAloneEngine/README.md index d2843dc1..a9a7d052 100644 --- a/examples/latest/navigate/ios/StandAloneEngine/README.md +++ b/examples/latest/navigate/ios/StandAloneEngine/README.md @@ -3,7 +3,7 @@ The StandAloneEngine example app shows how to use an engine without a map view. Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/Traffic/README.md b/examples/latest/navigate/ios/Traffic/README.md index f1dcea3d..1df233eb 100644 --- a/examples/latest/navigate/ios/Traffic/README.md +++ b/examples/latest/navigate/ios/Traffic/README.md @@ -3,7 +3,7 @@ The Traffic example app shows how to toggle traffic flow and traffic incidents v Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app. diff --git a/examples/latest/navigate/ios/UnitTesting/README.md b/examples/latest/navigate/ios/UnitTesting/README.md index 77c47ceb..6f3a9fe9 100644 --- a/examples/latest/navigate/ios/UnitTesting/README.md +++ b/examples/latest/navigate/ios/UnitTesting/README.md @@ -3,7 +3,7 @@ The UnitTesting example app shows how the HERE SDK can be mocked in unit tests. Build instructions: ------------------- -1) Copy the `heresdk.xcframework` file to your app's root folder. +1) Copy the `heresdk.xcframework` folder (as found in the HERE SDK package) to your app's root folder. Note: If your framework version is different than the version shown in the _Developer's Guide_, you may need to adapt the source code of the example app.