Skip to content

Commit eea101d

Browse files
WEBSDK-639 Update public examples to use HERE Maps API for JavaScript v3.2 (#176)
* Updated all the examples to use the latest major version HERE Maps API for JavaScript v3.2 --------- Co-authored-by: Daniele Bacarella <[email protected]>
1 parent 7d10366 commit eea101d

File tree

141 files changed

+3804
-6127
lines changed

Some content is hidden

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

141 files changed

+3804
-6127
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ See the [LICENSE](LICENSE) file in the root of this project for license details.
1111

1212
## Maps API for JavaScript
1313

14-
All of the following examples use **version 3.1** of the API
14+
All of the following examples use **version 3.2** of the API
1515

1616
* [Adding an Overlay to the Map](https://heremaps.github.io/maps-api-for-javascript-examples/custom-tile-overlay/demo.html) - Display custom map tiles as an overlay
1717
* [Animated Markers](https://heremaps.github.io/maps-api-for-javascript-examples/markers-update-position-with-animation/demo.html) - Update marker position with animation
1818
* [Calculating a Location from a Mouse Click](https://heremaps.github.io/maps-api-for-javascript-examples/position-on-mouse-click/demo.html) - Obtain the latitude and longitude of a location within the map
1919
* [Changing from the Metric System](https://heremaps.github.io/maps-api-for-javascript-examples/map-scale-bar-changing-from-the-metric-system/demo.html) - Display a map including a scale bar in miles or yards
2020
* [Circle on the Map](https://heremaps.github.io/maps-api-for-javascript-examples/circle-on-the-map/demo.html) - Display a map highlighting a circular region
21+
* [Context Menu](https://heremaps.github.io/maps-api-for-javascript-examples/context-menu/demo.html) - Adding a context menu to map objects
2122
* [DOM Marker](https://heremaps.github.io/maps-api-for-javascript-examples/map-with-dom-marker/demo.html) - Display a marker that is capable of receiving DOM events
2223
* [DOM Marker rotation](https://heremaps.github.io/maps-api-for-javascript-examples/dom-marker-rotation/demo.html) - Rotate DOM Marker's content using CSS
2324
* [Display KML Data](https://heremaps.github.io/maps-api-for-javascript-examples/display-kml-on-map/demo.html) - Parse a KML file and display the data on a map
@@ -62,7 +63,6 @@ All of the following examples use **version 3.1** of the API
6263
* [Search for a Location based on an Address](https://heremaps.github.io/maps-api-for-javascript-examples/geocode-a-location-from-address/demo.html) - Request a location using a free-form text input and display it on the map.
6364
* [Search for a Location given a Structured Address](https://heremaps.github.io/maps-api-for-javascript-examples/geocode-a-location-from-structured-address/demo.html) - Request a location from a structured address and display it on the map.
6465
* [Search for the Address of a Known Location](https://heremaps.github.io/maps-api-for-javascript-examples/reverse-geocode-an-address-from-location/demo.html) - Request address details for a given location and display it on the map.
65-
* [Set a map style at the load time](https://heremaps.github.io/maps-api-for-javascript-examples/change-style-at-load/demo.html) - Set a style of the whole map during the map instantiation
6666
* [Set a map style exported from the HERE Style Editor](https://heremaps.github.io/maps-api-for-javascript-examples/change-harp-style-at-load/demo.html) - Set a style exported from the [HERE Style Editor](https://platform.here.com/style-editor) during the map instantiation
6767
* [Synchronising Two Maps](https://heremaps.github.io/maps-api-for-javascript-examples/synchronising-two-maps/demo.html) - Synchronise a static map with an interactive map
6868
* [Take a Snapshot of the Map](https://heremaps.github.io/maps-api-for-javascript-examples/capture-map-area/demo.html) - Capture an area on the map

capture-map-area/demo.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@
55
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
66
<meta name="description" content="Capture an area on the map">
77
<title>Take a Snapshot of the Map</title>
8-
<link rel="stylesheet" type="text/css" href="https://js.api.here.com/v3/3.1/mapsjs-ui.css" />
8+
<link rel="stylesheet" type="text/css" href="https://js.api.here.com/v3/3.2/mapsjs-ui.css" />
99
<link rel="stylesheet" type="text/css" href="../template.css" />
1010
<link rel="stylesheet" type="text/css" href="demo.css" />
1111
<link rel="stylesheet" type="text/css" href="styles.css" />
1212
<script type="text/javascript" src='../test-credentials.js'></script>
13-
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-core.js"></script>
14-
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-service.js"></script>
15-
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-ui.js"></script>
16-
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-mapevents.js"></script>
13+
<script type="text/javascript" src="https://js.api.here.com/v3/3.2/mapsjs-core.js"></script>
14+
<script type="text/javascript" src="https://js.api.here.com/v3/3.2/mapsjs-service.js"></script>
15+
<script type="text/javascript" src="https://js.api.here.com/v3/3.2/mapsjs-ui.js"></script>
16+
<script type="text/javascript" src="https://js.api.here.com/v3/3.2/mapsjs-mapevents.js"></script>
1717
</head>
1818
<body id="capture-map-area">
1919
<div class="page-header">

capture-map-area/demo.js

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,23 @@ function capture(resultContainer, map, ui) {
99
// Capturing area of the map is asynchronous, callback function receives HTML5 canvas
1010
// element with desired map area rendered on it.
1111
// We also pass an H.ui.UI reference in order to see the ScaleBar in the output.
12-
// If dimensions are omitted, whole veiw port will be captured
13-
map.capture(function(canvas) {
14-
if (canvas) {
15-
resultContainer.innerHTML = '';
16-
resultContainer.appendChild(canvas);
17-
} else {
18-
// For example when map is in Panorama mode
19-
resultContainer.innerHTML = 'Capturing is not supported';
20-
}
21-
}, [ui], 50, 50, 500, 200);
12+
// If dimensions are omitted, whole view port will be captured
13+
map.capture(
14+
function (canvas) {
15+
if (canvas) {
16+
resultContainer.innerHTML = "";
17+
resultContainer.appendChild(canvas);
18+
} else {
19+
// For example when map is in Panorama mode
20+
resultContainer.innerHTML = "Capturing is not supported";
21+
}
22+
},
23+
[ui],
24+
50,
25+
50,
26+
500,
27+
200
28+
);
2229
}
2330

2431
/**
@@ -31,46 +38,45 @@ var platform = new H.service.Platform({
3138
});
3239
var defaultLayers = platform.createDefaultLayers();
3340

34-
var mapContainer = document.getElementById('map');
41+
var mapContainer = document.getElementById("map");
3542

3643
// Step 2: initialize a map
3744
var map = new H.Map(mapContainer, defaultLayers.vector.normal.map, {
3845
// initial center and zoom level of the map
3946
zoom: 16,
4047
// Champs-Elysees
41-
center: {lat: 48.869145, lng: 2.314298},
42-
pixelRatio: window.devicePixelRatio || 1
48+
center: { lat: 48.869145, lng: 2.314298 },
49+
pixelRatio: window.devicePixelRatio || 1,
4350
});
4451
// add a resize listener to make sure that the map occupies the whole container
45-
window.addEventListener('resize', () => map.getViewPort().resize());
52+
window.addEventListener("resize", () => map.getViewPort().resize());
4653

4754
// Step 3: make the map interactive
4855
// MapEvents enables the event system
4956
// Behavior implements default interactions for pan/zoom (also on mobile touch environments)
5057
var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
5158

5259
// Step 4: Create the default UI
53-
var ui = H.ui.UI.createDefault(map, defaultLayers, 'en-US');
54-
60+
var ui = H.ui.UI.createDefault(map, defaultLayers, "en-US");
5561

5662
// Step 6: Create "Capture" button and place for showing the captured area
57-
var resultContainer = document.getElementById('panel');
63+
var resultContainer = document.getElementById("panel");
5864

5965
// Create container for the "Capture" button
60-
var containerNode = document.createElement('div');
61-
containerNode.className = 'btn-group';
66+
var containerNode = document.createElement("div");
67+
containerNode.className = "btn-group";
6268

6369
// Create the "Capture" button
64-
var captureBtn = document.createElement('input');
65-
captureBtn.value = 'Capture';
66-
captureBtn.type = 'button';
67-
captureBtn.className = 'btn btn-sm btn-default';
70+
var captureBtn = document.createElement("input");
71+
captureBtn.value = "Capture";
72+
captureBtn.type = "button";
73+
captureBtn.className = "btn btn-sm btn-default";
6874

6975
// Add both button and container to the DOM
7076
containerNode.appendChild(captureBtn);
7177
mapContainer.appendChild(containerNode);
7278

7379
// Step 7: Handle capture button click event
74-
captureBtn.onclick = function() {
80+
captureBtn.onclick = function () {
7581
capture(resultContainer, map, ui);
76-
};
82+
};

change-harp-style-at-load/demo.html

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes">
55
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
66
<title>Set a map style exported from the HERE Style Editor</title>
7-
<link rel="stylesheet" type="text/css" href="https://js.api.here.com/v3/3.1/mapsjs-ui.css" />
7+
<link rel="stylesheet" type="text/css" href="https://js.api.here.com/v3/3.2/mapsjs-ui.css" />
88
<link rel="stylesheet" type="text/css" href="demo.css" />
99
<link rel="stylesheet" type="text/css" href="styles.css" />
1010
<link rel="stylesheet" type="text/css" href="../template.css" />
1111
<script type="text/javascript" src='../test-credentials.js'></script>
12-
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-core.js"></script>
13-
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-harp.js"></script>
14-
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-service.js"></script>
15-
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-ui.js"></script>
16-
<script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-mapevents.js"></script>
12+
<script type="text/javascript" src="https://js.api.here.com/v3/3.2/mapsjs-core.js"></script>
13+
<script type="text/javascript" src="https://js.api.here.com/v3/3.2/mapsjs-harp.js"></script>
14+
<script type="text/javascript" src="https://js.api.here.com/v3/3.2/mapsjs-service.js"></script>
15+
<script type="text/javascript" src="https://js.api.here.com/v3/3.2/mapsjs-ui.js"></script>
16+
<script type="text/javascript" src="https://js.api.here.com/v3/3.2/mapsjs-mapevents.js"></script>
1717
</head>
1818
<body id="markers-on-the-map">
1919
<div class="page-header">

change-harp-style-at-load/demo.js

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,29 @@ var platform = new H.service.Platform({
99
apikey: window.apikey
1010
});
1111

12-
// Step 2: specify engine type. In this example, we use HARP rendering engine, which is capable
13-
// of rendering vector data using the style configuration exported from the HERE Style Editor.
14-
// HARP engine is not the default engine, and it's not included in the mapsjs-core.js module.
15-
// To use this engine, you need to include mapsjs-harp.js file to your HTML page
16-
var engineType = H.Map.EngineType['HARP'];
17-
18-
// Step 3: create the style object from the style configuration
12+
// Step 2: create the style object from the style configuration
1913
// exported from the HERE Style Editor. The argument is a style path
20-
var style = new H.map.render.harp.Style('https://heremaps.github.io/maps-api-for-javascript-examples/change-harp-style-at-load/data/night.json');
14+
var style = new H.map.render.harp.Style(
15+
"https://heremaps.github.io/maps-api-for-javascript-examples/change-harp-style-at-load/data/night.json"
16+
);
2117

2218
// Step 4: create a layer with the style object:
23-
var vectorLayer = platform.getOMVService().createLayer(style, { engineType });
19+
var vectorLayer = platform.getOMVService().createLayer(style);
2420

2521
// Step 5: initialize a map
26-
var map = new H.Map(document.getElementById('map'),
27-
vectorLayer, {
28-
engineType,
29-
center: {lat: 52.51477270923461, lng: 13.39846691425174},
30-
zoom: 13,
31-
pixelRatio: window.devicePixelRatio || 1
32-
});
22+
var map = new H.Map(
23+
document.getElementById("map"),
24+
vectorLayer,
25+
{
26+
center: { lat: 52.51477270923461, lng: 13.39846691425174 },
27+
zoom: 13,
28+
pixelRatio: window.devicePixelRatio || 1,
29+
}
30+
);
3331
// add a resize listener to make sure that the map occupies the whole container
34-
window.addEventListener('resize', () => map.getViewPort().resize());
32+
window.addEventListener("resize", () => map.getViewPort().resize());
3533

3634
//Step 6: make the map interactive
3735
// MapEvents enables the event system
3836
// Behavior implements default interactions for pan/zoom (also on mobile touch environments)
39-
var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
37+
var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));

0 commit comments

Comments
 (0)