Skip to content

Commit

Permalink
Merge pull request #136 from heremaps/esd/41120
Browse files Browse the repository at this point in the history
Update example apps for release 4.11.2.0
  • Loading branch information
datasun authored Apr 29, 2022
2 parents 514d9de + 4f54b96 commit a4fbbad
Show file tree
Hide file tree
Showing 78 changed files with 1,847 additions and 833 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ For an overview of the existing features, please check the _Developer's Guide_ f

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

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

- HERE SDK for Android ([Lite Edition](lite/android/), [Explore Edition](explore/android/), [Navigate Edition](navigate/android/))
- HERE SDK for iOS ([Lite Edition](lite/ios/), [Explore Edition](explore/ios/), [Navigate Edition](navigate/ios/))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The CameraKeyframeTracks example app shows how to use multiple keyframe tracks for map camera animations and how to animate to a route. You can find how this is done in [CameraKeyframeTracksExample.java](app/src/main/java/com/here/camerakeyframetracks/animations/CameraKeyframeTracksExample.java).
The CameraKeyframeTracks example app shows how to use multiple keyframe tracks for map camera animations and how to animate to a route. You can find how this is done in [CameraKeyframeTracksExample.java](app/src/main/java/com/here/camerakeyframetracks/CameraKeyframeTracksExample.java).

Build instructions:
-------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* License-Filename: LICENSE
*/

package com.here.camerakeyframetracks.animations;
package com.here.camerakeyframetracks;

import android.util.Log;

Expand Down Expand Up @@ -84,16 +84,7 @@ private List<LocationKeyframeModel> createLocationsForTripToNYC() {
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
new LocationKeyframeModel(new GeoCoordinates(40.80253970834194, -73.93156255568137), Duration.ofMillis(3000)), // Vintage Autobody
new LocationKeyframeModel(new GeoCoordinates(40.79780371121212, -73.92238900253808), Duration.ofMillis(4000)), // Robert Kennedy Bridge
new LocationKeyframeModel(new GeoCoordinates(40.80771345637072, -73.93250541322794), Duration.ofMillis(3000)), // Third Avenue Bridge
new LocationKeyframeModel(new GeoCoordinates(40.820213148574766, -73.94930111845413), Duration.ofMillis(3000)), // City College NYC
new LocationKeyframeModel(new GeoCoordinates(40.84692287418771, -73.92803657908391), Duration.ofMillis(1500)), // Washington Bridge
new LocationKeyframeModel(new GeoCoordinates(40.85851487236918, -73.91388539084845), Duration.ofMillis(2000)), // Hall of Fame for Americans
new LocationKeyframeModel(new GeoCoordinates(40.87784894879347, -73.92238697760786), Duration.ofMillis(2000)), // Henry Hudson Bridge
new LocationKeyframeModel(new GeoCoordinates(40.881034859141806, -73.920040015101), Duration.ofMillis(1500)), // Henry Hudson Park
new LocationKeyframeModel(new GeoCoordinates(41.067415618493946, -73.86134115274218), Duration.ofMillis(1500)) // Transfiguration Church
new LocationKeyframeModel(new GeoCoordinates(40.78255966255712, -73.9586425508515), Duration.ofMillis(3000)) // Solomon Museum
);

return locationList;
Expand Down Expand Up @@ -122,8 +113,10 @@ private List<ScalarKeyframeModel> createScalarsForTripToNYC() {
List<ScalarKeyframeModel> scalarList = new ArrayList<>();

scalarList.add(new ScalarKeyframeModel(80000000.0, Duration.ofMillis(0)));
scalarList.add(new ScalarKeyframeModel(8000000.0, Duration.ofMillis(4000)));
scalarList.add(new ScalarKeyframeModel(500.0, Duration.ofMillis(5000)));
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)));

return scalarList;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,25 @@

package com.here.camerakeyframetracks;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;

import com.here.camerakeyframetracks.animations.CameraKeyframeTracksExample;
import com.here.camerakeyframetracks.animations.RouteAnimationExample;
import androidx.annotation.NonNull;
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.mapview.MapError;
import com.here.sdk.mapview.MapScene;
import com.here.sdk.mapview.MapScheme;
import com.here.sdk.mapview.MapView;
import com.here.sdk.mapview.VisibilityState;
import com.here.sdk.routing.Route;

public class MainActivity extends AppCompatActivity {

Expand Down Expand Up @@ -88,37 +87,16 @@ private void loadMapScene() {
public void onLoadScene(@Nullable MapError mapError) {
if (mapError == null) {
mapView.getMapScene().setLayerVisibility(MapScene.Layers.LANDMARKS, VisibilityState.VISIBLE);

double distanceInMeters = 5000;
mapView.getCamera().lookAt(new GeoCoordinates(40.7116777285189, -74.01248494562448), distanceInMeters);

mapView.getCamera().lookAt(new GeoCoordinates(40.7133, -74.0112));
cameraKeyframeTracksExample = new CameraKeyframeTracksExample(mapView);
routeAnimationExample = new RouteAnimationExample(mapView, MainActivity.this);
routeAnimationExample = new RouteAnimationExample(mapView);
} else {
Log.d(TAG, "onLoadScene failed: " + mapError.toString());
}
}
});
}

@Override
protected void onPause() {
super.onPause();
mapView.onPause();
}

@Override
protected void onResume() {
super.onResume();
mapView.onResume();
}

@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater=getMenuInflater();
Expand All @@ -128,34 +106,23 @@ 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()) {
// An animation that moves the camera along a route.
case R.id.calculateRoute:
routeAnimationExample.calculateRoute();
return true;
case R.id.startRouteAnimation:
Route route = routeAnimationExample.calculateRoute();
if (route != null) {
routeAnimationExample.animateRoute(route);
} else {
routeAnimationExample.showDialog("Route Empty: ", "Please create a route.");
}
// An animation that moves the camera along a route.
routeAnimationExample.animateRoute(RouteCalculator.testRoute);
return true;
case R.id.stopRouteAnimation:
case R.id.stopToRouteAnimation:
routeAnimationExample.stopRouteAnimation();
return true;
case R.id.clearMap:
routeAnimationExample.clearRoute();
return true;
case R.id.startToRouteAnimation:
// An animation that moves the camera to the route without keyframe tracks.
route = routeAnimationExample.calculateRoute();
if (route != null) {
routeAnimationExample.animateToRoute(route);
} else {
routeAnimationExample.showDialog("Route Empty: ", "Please create a route.");
}
routeAnimationExample.animateToRoute(RouteCalculator.testRoute);
return true;
case R.id.startNYCAnimation:
// A camera animation through New York.
Expand All @@ -168,4 +135,22 @@ public boolean onOptionsItemSelected(@NonNull MenuItem item) {
return super.onOptionsItemSelected(item);
}
}

@Override
protected void onPause() {
super.onPause();
mapView.onPause();
}

@Override
protected void onResume() {
super.onResume();
mapView.onResume();
}

@Override
protected void onDestroy() {
super.onDestroy();
mapView.onDestroy();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,11 @@
* License-Filename: LICENSE
*/

package com.here.camerakeyframetracks.animations;
package com.here.camerakeyframetracks;

import android.content.Context;
import android.util.Log;

import androidx.appcompat.app.AlertDialog;

import com.here.camerakeyframetracks.RouteCalculator;
import com.here.camerakeyframetracks.helper.RouteCalculator;
import com.here.camerakeyframetracks.models.LocationKeyframeModel;
import com.here.camerakeyframetracks.models.OrientationKeyframeModel;
import com.here.camerakeyframetracks.models.ScalarKeyframeModel;
Expand All @@ -33,10 +30,12 @@
import com.here.sdk.animation.GeoOrientationKeyframe;
import com.here.sdk.animation.KeyframeInterpolationMode;
import com.here.sdk.animation.ScalarKeyframe;
import com.here.sdk.core.Color;
import com.here.sdk.core.GeoCoordinates;
import com.here.sdk.core.GeoOrientation;
import com.here.sdk.core.GeoPolyline;
import com.here.sdk.core.GeoOrientationUpdate;
import com.here.sdk.core.Point2D;
import com.here.sdk.core.Rectangle2D;
import com.here.sdk.core.Size2D;
import com.here.sdk.mapview.MapCameraAnimation;
import com.here.sdk.mapview.MapCameraAnimationFactory;
import com.here.sdk.mapview.MapCameraKeyframeTrack;
Expand All @@ -45,67 +44,22 @@
import com.here.sdk.mapview.MapPolyline;
import com.here.sdk.mapview.MapView;
import com.here.sdk.routing.Route;
import com.here.sdk.routing.Waypoint;
import com.here.time.Duration;

import java.util.ArrayList;
import java.util.List;

public class RouteAnimationExample {

private final Context context;
private final MapView mapView;
private final List<MapPolyline> mapPolylines = new ArrayList<>();
private final RouteCalculator routeCalculator;
private Route route;

public RouteAnimationExample(MapView mapView, Context context) {
public RouteAnimationExample(MapView mapView) {
this.mapView = mapView;
this.context = context;

routeCalculator = new RouteCalculator();
}

public Route calculateRoute() {
double distanceInMeters = 5000;
mapView.getCamera().lookAt(new GeoCoordinates(40.7116777285189, -74.01248494562448), distanceInMeters);

// Calculates a car route.
routeCalculator.calculateRoute((routingError, routes) -> {
if (routingError == null) {
route = routes.get(0);
showRouteOnMap(route);
} else {
showDialog("Error while calculating a route:", routingError.toString());
}
});

return route;
}

private void showRouteOnMap(Route route) {
// Show route as polyline.
GeoPolyline routeGeoPolyline = route.getGeometry();
float widthInPixels = 20;
MapPolyline routeMapPolyline = new MapPolyline(routeGeoPolyline,
widthInPixels,
Color.valueOf(0, 0.56f, 0.54f, 0.63f)); // RGBA
mapView.getMapScene().addMapPolyline(routeMapPolyline);
mapPolylines.add(routeMapPolyline);
}

public void clearRoute() {
for (MapPolyline mapPolyline : mapPolylines) {
mapView.getMapScene().removeMapPolyline(mapPolyline);
}
mapPolylines.clear();
}

public void showDialog(String title, String message) {
AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title)
.setMessage(message)
.show();
// Creates a fixed route for testing purposes.
routeCalculator = new RouteCalculator(mapView);
routeCalculator.createRoute();
}

List<LocationKeyframeModel> createLocationsForRouteAnimation(Route route) {
Expand Down Expand Up @@ -198,8 +152,21 @@ public void stopRouteAnimation() {
}

public void animateToRoute(Route route) {
MapCameraUpdate update = MapCameraUpdateFactory.lookAt(route.getBoundingBox());
MapCameraAnimation animation = MapCameraAnimationFactory.createAnimation(update, Duration.ofMillis(3000), EasingFunction.IN_CUBIC);
// Untilt and unrotate the 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());
Rectangle2D mapViewport = new Rectangle2D(origin, sizeInPixels);

// Animate to route.
MapCameraUpdate update = MapCameraUpdateFactory.lookAt(
route.getBoundingBox(),
new GeoOrientationUpdate(bearing, tilt),
mapViewport);
MapCameraAnimation animation =
MapCameraAnimationFactory.createAnimation(update, Duration.ofMillis(3000), EasingFunction.IN_CUBIC);
mapView.getCamera().startAnimation(animation);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* License-Filename: LICENSE
*/

package com.here.camerakeyframetracks;
package com.here.camerakeyframetracks.helper;

import android.Manifest;
import android.app.Activity;
Expand Down
Loading

0 comments on commit a4fbbad

Please sign in to comment.