Skip to content

Commit 7b5b829

Browse files
Merge pull request #435 from heremaps/esd/42600
Update example apps for release 4.26.0.0
2 parents dc60944 + e361c53 commit 7b5b829

471 files changed

Lines changed: 9329 additions & 1320 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ For an overview of the existing features, please check the _Developer Guide_ for
2626

2727
> For now, HERE SDK (Navigate) is only available upon request. Please contact your HERE representative to receive access including a set of evaluation credentials.
2828
29-
## List of available example apps (Version 4.25.5.0)
29+
## List of available example apps (Version 4.26.0.0)
3030

3131
- [List of example apps for the HERE SDK for Android](https://www.here.com/docs/bundle/sdk-for-android-developer-guide/page/topics/examples.html).
3232
- [List of example apps for the HERE SDK for iOS](https://www.here.com/docs/bundle/sdk-for-ios-developer-guide/page/topics/examples.html).

examples/latest/README.md

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

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

examples/latest/explore/android/Java/Camera/app/libs/here-sdk-units-core-release-v1.0.aar renamed to examples/latest/explore/android/Java/Camera/app/libs/here-sdk-units-core-release-v1.2.aar

152 KB
Binary file not shown.

examples/latest/explore/android/Java/CameraKeyframeTracks/app/libs/here-sdk-units-core-release-v1.0.aar renamed to examples/latest/explore/android/Java/CameraKeyframeTracks/app/libs/here-sdk-units-core-release-v1.2.aar

152 KB
Binary file not shown.

examples/latest/explore/android/Java/CameraKeyframeTracks/app/src/main/java/com/here/camerakeyframetracks/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ public void permissionsDenied() {
104104
@Override
105105
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
106106
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
107-
permissionsRequestor.onRequestPermissionsResult(requestCode, grantResults);
107+
permissionsRequestor.onRequestPermissionsResult(requestCode, permissions, grantResults);
108108
}
109109

110110
private void loadMapScene() {

examples/latest/explore/android/Java/CustomMapStyles/app/libs/here-sdk-units-core-release-v1.0.aar renamed to examples/latest/explore/android/Java/CustomMapStyles/app/libs/here-sdk-units-core-release-v1.2.aar

152 KB
Binary file not shown.

examples/latest/explore/android/Java/CustomPolygonLayers/app/libs/here-sdk-units-core-release-v1.0.aar renamed to examples/latest/explore/android/Java/CustomPolygonLayers/app/libs/here-sdk-units-core-release-v1.2.aar

152 KB
Binary file not shown.

examples/latest/explore/android/Java/CustomRasterLayers/app/src/main/java/com/here/sdk/customrasterlayers/CustomRasterLayersExample.java

Lines changed: 67 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*
1+
/*
22
* Copyright (C) 2019-2026 HERE Europe B.V.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +21,7 @@
2121

2222
import android.content.Context;
2323

24-
import com.here.sdk.mapview.MapCameraLimits;
24+
import com.here.sdk.mapview.MapCameraLimits;
2525
import com.here.sdk.core.Anchor2D;
2626
import com.here.sdk.core.GeoCoordinates;
2727
import com.here.sdk.mapview.MapCamera;
@@ -49,49 +49,75 @@ public class CustomRasterLayersExample {
4949
private static final float DEFAULT_DISTANCE_TO_EARTH_IN_METERS = 60 * 1000;
5050

5151
private MapView mapView;
52-
private MapLayer rasterMapLayerStyle;
53-
private RasterDataSource rasterDataSourceStyle;
5452
private Context context;
5553

56-
public void onMapSceneLoaded(MapView mapView, Context context) {
54+
private MapLayer outdoorLayer;
55+
private RasterDataSource outdoorDataSource;
56+
private MapLayer transportLayer;
57+
private RasterDataSource transportDataSource;
58+
59+
public CustomRasterLayersExample(MapView mapView, Context context) {
5760
this.mapView = mapView;
5861
this.context = context;
5962

63+
initializeRasterLayers();
64+
6065
MapCamera camera = mapView.getCamera();
6166
MapMeasure mapMeasureZoom = new MapMeasure(MapMeasure.Kind.DISTANCE_IN_METERS, DEFAULT_DISTANCE_TO_EARTH_IN_METERS);
6267
camera.lookAt(new GeoCoordinates(52.530932, 13.384915), mapMeasureZoom);
6368

64-
String dataSourceName = "myRasterDataSourceStyle";
65-
rasterDataSourceStyle = createRasterDataSource(dataSourceName);
66-
rasterMapLayerStyle = createMapLayer(dataSourceName);
67-
68-
// We want to start with the default map style.
69-
rasterMapLayerStyle.setEnabled(false);
70-
71-
// Add a POI marker
69+
// Add a POI marker at the camera location to demonstrate marker rendering above custom raster layers.
7270
addPOIMapMarker(new GeoCoordinates(52.530932, 13.384915));
7371
}
7472

75-
public void enableButtonClicked() {
76-
rasterMapLayerStyle.setEnabled(true);
77-
}
78-
79-
public void disableButtonClicked() {
80-
rasterMapLayerStyle.setEnabled(false);
81-
}
82-
83-
private RasterDataSource createRasterDataSource(String dataSourceName) {
84-
// Note: As an example, below is an URL template of an outdoor layer from thunderforest.com.
73+
private void initializeRasterLayers() {
74+
// Note: As an example, below are URL templates of an outdoor and a transport layer from thunderforest.com.
8575
// On their web page you can register a key. Without setting a valid API key, the tiles will
8676
// show a watermark.
8777
// More details on the terms of usage can be found here: https://www.thunderforest.com/terms/
8878
// For example, your application must have working links to https://www.thunderforest.com
8979
// and https://www.osm.org/copyright.
90-
// For the below template URL, please pay attention to the following attribution:
80+
// For the below URL templates, please pay attention to the following attribution:
9181
// Maps © www.thunderforest.com, Data © www.osm.org/copyright.
9282
// Alternatively, choose another tile provider or use the (customizable) map styles provided by HERE.
93-
String templateUrl = "https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png";
83+
String templateUrlOutdoors = "https://tile.thunderforest.com/outdoors/{z}/{x}/{y}.png";
84+
String templateUrlTransport = "https://tile.thunderforest.com/transport/{z}/{x}/{y}.png";
85+
86+
String outdoorDataSourceName = "myRasterDataSourceStyleOutdoors";
87+
outdoorDataSource = createRasterDataSourceWithTemplate(
88+
outdoorDataSourceName,
89+
templateUrlOutdoors);
90+
outdoorLayer = createMapLayer(outdoorDataSourceName);
91+
outdoorLayer.setEnabled(false);
92+
93+
String transportDataSourceName = "myRasterDataSourceStyleTransport";
94+
transportDataSource = createRasterDataSourceWithTemplate(
95+
transportDataSourceName,
96+
templateUrlTransport);
97+
transportLayer = createMapLayer(transportDataSourceName);
98+
transportLayer.setEnabled(false);
99+
}
100+
101+
public void enableOutdoorLayer() {
102+
outdoorLayer.setEnabled(true);
103+
}
94104

105+
public void enableTransportLayer() {
106+
transportLayer.setEnabled(true);
107+
}
108+
109+
// Explicitly disable only the Outdoors layer.
110+
public void disableOutdoorLayer() {
111+
outdoorLayer.setEnabled(false);
112+
}
113+
114+
// Explicitly disable only the Transport layer.
115+
public void disableTransportLayer() {
116+
transportLayer.setEnabled(false);
117+
}
118+
119+
// Generic helper to create a raster data source for a given name and tile URL template.
120+
private RasterDataSource createRasterDataSourceWithTemplate(String dataSourceName, String templateUrl) {
95121
// The storage levels available for this data source. Supported range [0, 31].
96122
List<Integer> storageLevels = Arrays.asList(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16);
97123
RasterDataSourceConfiguration.Provider rasterProviderConfig = new RasterDataSourceConfiguration.Provider(
@@ -102,9 +128,10 @@ private RasterDataSource createRasterDataSource(String dataSourceName) {
102128
// If you want to add transparent layers then set this to true.
103129
rasterProviderConfig.hasAlphaChannel = false;
104130

105-
// Raster tiles are stored in a separate cache on the device.
106-
String path = "cache/raster/mycustomlayer";
107-
long maxDiskSizeInBytes = 1024 * 1024 * 128; // 128
131+
// Use a dedicated cache path per data source to keep layers separated on disk.
132+
// Raster tiles are stored in a separate cache, independent from the map cache used for vector data.
133+
String path = "cache/raster/" + dataSourceName;
134+
long maxDiskSizeInBytes = 1024 * 1024 * 128; // 128 MB
108135
RasterDataSourceConfiguration.Cache cacheConfig = new RasterDataSourceConfiguration.Cache(path, maxDiskSizeInBytes);
109136

110137
// Note that this will make the raster source already known to the passed map view.
@@ -136,8 +163,18 @@ private MapLayer createMapLayer(String dataSourceName) {
136163
}
137164

138165
public void onDestroy() {
139-
rasterMapLayerStyle.destroy();
140-
rasterDataSourceStyle.destroy();
166+
if (outdoorLayer != null) {
167+
outdoorLayer.destroy();
168+
}
169+
if (outdoorDataSource != null) {
170+
outdoorDataSource.destroy();
171+
}
172+
if (transportLayer != null) {
173+
transportLayer.destroy();
174+
}
175+
if (transportDataSource != null) {
176+
transportDataSource.destroy();
177+
}
141178
}
142179

143180
private void addPOIMapMarker(GeoCoordinates geoCoordinates) {

0 commit comments

Comments
 (0)