Skip to content

Commit b32e6c4

Browse files
committed
Fixed contex-menu and multi language support examples
Signed-off-by: Tomas Tobis <[email protected]>
1 parent 0e3af27 commit b32e6c4

File tree

7 files changed

+23
-18
lines changed

7 files changed

+23
-18
lines changed
File renamed without changes.
File renamed without changes.
File renamed without changes.

context_menu/demo.js context-menu/demo.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99
function addContextMenus(map) {
1010
// First we need to subscribe to the "contextmenu" event on the map
1111
map.addEventListener('contextmenu', function (e) {
12+
// As we already handle contextmenu event callback on circle object,
13+
// we don't do anything if target is different than the map.
14+
if (e.target !== map) {
15+
return;
16+
}
17+
1218
// "contextmenu" event might be triggered not only by a pointer,
1319
// but a keyboard button as well. That's why ContextMenuEvent
1420
// doesn't have a "currentPointer" property.
@@ -73,8 +79,7 @@ function addCircle(coord) {
7379
callback: function() {
7480
map.removeObject(circle);
7581
}
76-
}),
77-
H.util.ContextItem.SEPARATOR
82+
})
7883
);
7984
});
8085

@@ -109,4 +114,4 @@ var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
109114
var ui = H.ui.UI.createDefault(map, defaultLayers);
110115

111116
// Step 5: main logic
112-
addContextMenus(map);
117+
addContextMenus(map);
File renamed without changes.

map-multi-language-support/demo.js

+8-14
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,17 @@
1-
1+
22
/**
33
* Switches the map language to simplified Chinese
44
*
55
* @param {H.Map} map A HERE Map instance within the application
66
* @pama {H.service.Platform} platform A stub class to access HERE services
77
*/
88
function switchMapLanguage(map, platform){
9-
var mapTileService = platform.getMapTileService({
10-
type: 'base'
11-
}),
12-
// Our layer will load tiles from the HERE Map Tile API
13-
chineseMapLayer = mapTileService.createTileLayer(
14-
'maptile',
15-
'normal.day',
16-
pixelRatio === 1 ? 256 : 512,
17-
'png8',
18-
{lg: 'CHI', ppi: pixelRatio === 1 ? undefined : 320}
19-
);
20-
map.setBaseLayer(chineseMapLayer);
9+
// Create default layers
10+
let defaultLayers = platform.createDefaultLayers({
11+
lg: 'zh'
12+
});
13+
// Set the normal map variant of the vector map type
14+
map.setBaseLayer(defaultLayers.vector.normal.map);
2115

2216
// Display default UI components on the map and change default
2317
// language to simplified Chinese.
@@ -63,4 +57,4 @@ window.addEventListener('resize', () => map.getViewPort().resize());
6357
var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
6458

6559
// Now use the map as required...
66-
switchMapLanguage(map, platform);
60+
switchMapLanguage(map, platform);

meta.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"uid": "map-multi-language-support",
5858
"title": "Multi-language support",
5959
"shortDescription": "Display a map with labels in a foreign language",
60-
"published": false
60+
"published": true
6161
},
6262
{
6363
"uid": "map-scale-bar-changing-from-the-metric-system",
@@ -251,6 +251,12 @@
251251
"title": "Map Objects Event Delegation",
252252
"shortDescription": "Use event delegation on map objects",
253253
"published": true
254+
},
255+
{
256+
"uid": "context-menu",
257+
"title": "Context menu",
258+
"shortDescription": "Add a context menu to map and map object",
259+
"published": true
254260
}
255261
]
256262
},

0 commit comments

Comments
 (0)