Skip to content

Commit

Permalink
Merge pull request #160 from heremaps/esd/41230
Browse files Browse the repository at this point in the history
Update example apps for release 4.12.3.0
  • Loading branch information
maharudraabhishek authored Aug 5, 2022
2 parents 67ca0d1 + 9c3d69b commit 47ad352
Show file tree
Hide file tree
Showing 37 changed files with 310 additions and 135 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ For an overview of the existing features, please check the _Developer'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.12.2.0)
## List of Available Example Apps (Version 4.12.3.0)

- **HelloMap**: Shows the classic 'Hello World'.
- **HelloMapKotlin**: Shows the classic 'Hello World' using Kotlin language (Android only).
Expand Down
2 changes: 1 addition & 1 deletion examples/latest/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This folder contains the HERE SDK examples apps for version: 4.12.2.0
This folder contains the HERE SDK examples apps for version: 4.12.3.0

- HERE SDK for Android ([Lite Edition](lite/android/), [Explore Edition](explore/android/), [Navigate Edition](navigate/android/))
- HERE SDK for iOS ([Lite Edition](lite/ios/), [Explore Edition](explore/ios/), [Navigate Edition](navigate/ios/))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ private RasterDataSource createRasterDataSource(String dataSourceName) {

// Raster tiles are stored in a separate cache on the device.
String path = "cache/raster/toner";
long maxDiskSizeInBytes = 1024 * 1024 * 32;
long maxDiskSizeInBytes = 1024 * 1024 * 128; // 128
RasterDataSourceConfiguration.Cache cacheConfig = new RasterDataSourceConfiguration.Cache(path, maxDiskSizeInBytes);

// Note that this will make the raster source already known to the passed map view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
import com.here.sdk.mapview.MapScene;
import com.here.sdk.mapview.MapScheme;
import com.here.sdk.mapview.MapView;
import com.here.sdk.mapview.VisibilityState;

public class MainActivity extends AppCompatActivity {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import androidx.appcompat.app.AlertDialog;

import com.here.sdk.core.Anchor2D;
import com.here.sdk.core.Color;
import com.here.sdk.core.GeoCoordinates;
import com.here.sdk.core.GeoOrientationUpdate;
import com.here.sdk.core.Location;
Expand Down Expand Up @@ -101,20 +102,36 @@ public void showCenteredMapMarkers() {
}

public void showMapMarkerCluster() {
MapImage clusterMapImage = MapImageFactory.fromResource(context.getResources(), R.drawable.blue_square);
MapMarkerCluster mapMarkerCluster = new MapMarkerCluster(new MapMarkerCluster.ImageStyle(clusterMapImage));
MapImage clusterMapImage = MapImageFactory.fromResource(context.getResources(), R.drawable.green_square);

// Defines a text that indicates how many markers are included in the cluster.
MapMarkerCluster.CounterStyle counterStyle = new MapMarkerCluster.CounterStyle();
counterStyle.textColor = new Color(0, 0, 0, 1); // Black
counterStyle.fontSize = 40;
counterStyle.maxCountNumber = 9;
counterStyle.aboveMaxText = "+9";

MapMarkerCluster mapMarkerCluster = new MapMarkerCluster(
new MapMarkerCluster.ImageStyle(clusterMapImage), counterStyle);
mapView.getMapScene().addMapMarkerCluster(mapMarkerCluster);
mapMarkerClusterList.add(mapMarkerCluster);

for (int i = 0; i < 10; i++) {
mapMarkerCluster.addMapMarker(createRandomMapMarkerInViewport());
mapMarkerCluster.addMapMarker(createRandomMapMarkerInViewport("" + i));
}
}

private MapMarker createRandomMapMarkerInViewport() {
private MapMarker createRandomMapMarkerInViewport(String metaDataText) {
GeoCoordinates geoCoordinates = createRandomGeoCoordinatesAroundMapCenter();
MapImage mapImage = MapImageFactory.fromResource(context.getResources(), R.drawable.green_square);
return new MapMarker(geoCoordinates, mapImage);

MapMarker mapMarker = new MapMarker(geoCoordinates, mapImage);

Metadata metadata = new Metadata();
metadata.setString("key_cluster", metaDataText);
mapMarker.setMetadata(metadata);

return mapMarker;
}

public void showLocationIndicatorPedestrian() {
Expand Down Expand Up @@ -403,14 +420,32 @@ private void handlePickedMapMarkerClusters(PickMapItemsResult pickMapItemsResult
}
if (clusterSize == 1) {
showDialog("Map marker picked",
"This MapMarker belongs to a cluster.");
"This MapMarker belongs to a cluster. Metadata: " + getClusterMetadata(topmostGrouping.markers.get(0)));
} else {
String metadata = "";
for (MapMarker mapMarker: topmostGrouping.markers) {
metadata += getClusterMetadata(mapMarker);
metadata += " ";
}
showDialog("Map marker cluster picked",
"Number of contained markers in this cluster: " + clusterSize + ". " +
"Contained Metadata: " + metadata + ". " +
"Total number of markers in this MapMarkerCluster: " + topmostGrouping.parent.getMarkers().size());
}
}

private String getClusterMetadata(MapMarker mapMarker) {
Metadata metadata = mapMarker.getMetadata();
String message = "No metadata.";
if (metadata != null) {
String string = metadata.getString("key_cluster");
if (string != null) {
message = string;
}
}
return message;
}

private void tiltMap() {
double bearing = mapView.getCamera().getState().orientationAtTarget.bearing;
double tilt = 60;
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class CustomRasterLayersExample {

// Raster tiles are stored in a separate cache on the device.
String path = "cache/raster/toner";
int maxDiskSizeInBytes = 1024 * 1024 * 32;
int maxDiskSizeInBytes = 1024 * 1024 * 128; // 128 MB
RasterDataSourceCacheConfiguration cacheConfig = RasterDataSourceCacheConfiguration(path, maxDiskSizeInBytes);

// Note that this will make the raster source already known to the passed map view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
android:label="Hello Map"
android:icon="@mipmap/ic_launcher">

<!-- Set the credentials for the HERE SDK here! -->
<meta-data android:name="com.here.sdk.access_key_id" android:value="YOUR_ACCESS_KEY_ID"/>
<meta-data android:name="com.here.sdk.access_key_secret" android:value="YOUR_ACCESS_KEY_SECRET"/>

<activity
android:name=".MainActivity"
android:exported="true"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>HERECredentials</key>
<dict>
<key>AccessKeyId</key>
<string>YOUR_ACCESS_KEY_ID</string>
<key>AccessKeySecret</key>
<string>YOUR_ACCESS_KEY_SECRET</string>
</dict>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down
21 changes: 1 addition & 20 deletions examples/latest/explore/flutter/hello_map_app/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,11 @@

import 'package:flutter/material.dart';
import 'package:here_sdk/core.dart';
import 'package:here_sdk/core.engine.dart';
import 'package:here_sdk/core.errors.dart';
import 'package:here_sdk/mapview.dart';

void main() async {
// Usually, you need to initialize the HERE SDK only once during the lifetime of an application.
_initializeHERESDK();
runApp(MyApp());
}

void _initializeHERESDK() async {
// Needs to be called before accessing SDKOptions to load necessary libraries.
SdkContext.init(IsolateOrigin.main);

// Set your credentials for the HERE SDK.
String accessKeyId = "YOUR_ACCESS_KEY_ID";
String accessKeySecret = "YOUR_ACCESS_KEY_SECRET";
SDKOptions sdkOptions = SDKOptions.withAccessKeySecret(accessKeyId, accessKeySecret);

try {
await SDKNativeEngine.makeSharedInstance(sdkOptions);
} on InstantiationException {
throw Exception("Failed to initialize the HERE SDK.");
}
runApp(MyApp());
}

class MyApp extends StatelessWidget {
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* License-Filename: LICENSE
*/

import 'dart:io';
import 'dart:math';
import 'dart:typed_data';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:here_sdk/core.dart';
import 'package:here_sdk/gestures.dart';
Expand Down Expand Up @@ -86,27 +86,40 @@ class MapItemsExample {
Future<void> showMapMarkerCluster() async {
// Reuse existing MapImage for new map markers.
if (_blueSquareMapImage == null) {
Uint8List imagePixelData = await _loadFileAsUint8List('assets/blue_square.png');
Uint8List imagePixelData = await _loadFileAsUint8List('assets/green_square.png');
_blueSquareMapImage = MapImage.withPixelDataAndImageFormat(imagePixelData, ImageFormat.png);
}

MapMarkerCluster mapMarkerCluster = MapMarkerCluster(MapMarkerClusterImageStyle(_blueSquareMapImage!));
// Defines a text that indicates how many markers are included in the cluster.
MapMarkerClusterCounterStyle counterStyle = MapMarkerClusterCounterStyle();
counterStyle.textColor = Colors.black;
counterStyle.fontSize = 40;
counterStyle.maxCountNumber = 9;
counterStyle.aboveMaxText = "+9";

MapMarkerCluster mapMarkerCluster =
MapMarkerCluster.WithCounter(MapMarkerClusterImageStyle(_blueSquareMapImage!), counterStyle);
_hereMapController.mapScene.addMapMarkerCluster(mapMarkerCluster);
_mapMarkerClusterList.add(mapMarkerCluster);

for (int i = 0; i < 10; i++) {
mapMarkerCluster.addMapMarker(await _createRandomMapMarkerInViewport());
mapMarkerCluster.addMapMarker(await _createRandomMapMarkerInViewport(i.toString()));
}
}

Future<MapMarker> _createRandomMapMarkerInViewport() async {
Future<MapMarker> _createRandomMapMarkerInViewport(String metaDataText) async {
// Reuse existing MapImage for new map markers.
if (_greenSquareMapImage == null) {
Uint8List imagePixelData = await _loadFileAsUint8List('assets/green_square.png');
_greenSquareMapImage = MapImage.withPixelDataAndImageFormat(imagePixelData, ImageFormat.png);
}

MapMarker mapMarker = MapMarker(_createRandomGeoCoordinatesAroundMapCenter(), _greenSquareMapImage!);

Metadata metadata = new Metadata();
metadata.setString("key_cluster", metaDataText);
mapMarker.metadata = metadata;

return mapMarker;
}

Expand Down Expand Up @@ -259,7 +272,6 @@ class MapItemsExample {
}

void _addFlatMarker(GeoCoordinates geoCoordinates) async {

Uint8List imagePixelData = await _loadFileAsUint8List('assets/poi.png');
MapImage mapImage = MapImage.withPixelDataAndImageFormat(imagePixelData, ImageFormat.png);

Expand All @@ -268,7 +280,8 @@ class MapItemsExample {
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);
MapMarker3D mapMarker3D =
MapMarker3D.fromImage(geoCoordinates, mapImage, scaleFactor, RenderSizeUnit.densityIndependentPixels);

_hereMapController.mapScene.addMapMarker3d(mapMarker3D);
_mapMarker3DList.add(mapMarker3D);
Expand Down Expand Up @@ -316,7 +329,8 @@ class MapItemsExample {
// 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.
var altitude = 18.0;
GeoCoordinates geoCoordinatesWithAltitude = GeoCoordinates.withAltitude(geoCoordinates.latitude, geoCoordinates.longitude, altitude);
GeoCoordinates geoCoordinatesWithAltitude =
GeoCoordinates.withAltitude(geoCoordinates.latitude, geoCoordinates.longitude, altitude);

// Optionally, consider to store the model for reuse (like we showed for MapImages above).
MapMarker3DModel mapMarker3DModel = MapMarker3DModel.withTextureFilePath(geometryFilePath, textureFilePath);
Expand Down Expand Up @@ -385,16 +399,37 @@ class MapItemsExample {
return;
}
if (clusterSize == 1) {
_showDialog("Map marker picked", "This MapMarker belongs to a cluster.");
_showDialog("Map marker picked",
"This MapMarker belongs to a cluster. Metadata: " + _getClusterMetadata(topmostGrouping.markers.first));
} else {
String metadata = "";
topmostGrouping.markers.forEach((element) {
metadata += _getClusterMetadata(element);
metadata += " ";
});
int totalSize = topmostGrouping.parent.markers.length;
_showDialog(
"Map marker cluster picked",
"Number of contained markers in this cluster: $clusterSize." +
"Contained Metadata: " +
metadata +
". " +
"Total number of markers in this MapMarkerCluster: $totalSize.");
}
}

String _getClusterMetadata(MapMarker mapMarker) {
Metadata? metadata = mapMarker.metadata;
String message = "No metadata.";
if (metadata != null) {
String? string = metadata.getString("key_cluster");
if (string != null) {
message = string;
}
}
return message;
}

void _tiltMap() {
double bearing = _hereMapController.camera.state.orientationAtTarget.bearing;
double tilt = 60;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class CustomRasterLayersExample {

// Raster tiles are stored in a separate cache on the device.
let path = "cache/raster/toner"
let maxDiskSizeInBytes: Int64 = 1024 * 1024 * 32
let maxDiskSizeInBytes: Int64 = 1024 * 1024 * 128 // 128 MB
let cacheConfig = RasterDataSourceConfiguration.Cache(path: path,
diskSize: maxDiskSizeInBytes)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ class CarPlayViewController: UIViewController {
let camera = mapView.camera
let distanceInMeters = MapMeasure(kind: .distance, value: 1000 * 10)
camera.lookAt(point: GeoCoordinates(latitude: 52.518043, longitude: 13.405991), zoom: distanceInMeters)

// Optionally enable textured 3D landmarks.
mapView.mapScene.setLayerVisibility(layerName: MapScene.Layers.landmarks, visibility: VisibilityState.visible)
}

public func zoomIn() {
Expand Down

This file was deleted.

Binary file not shown.
Loading

0 comments on commit 47ad352

Please sign in to comment.