File tree 7 files changed +23
-18
lines changed
map-multi-language-support
7 files changed +23
-18
lines changed File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 9
9
function addContextMenus ( map ) {
10
10
// First we need to subscribe to the "contextmenu" event on the map
11
11
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
+
12
18
// "contextmenu" event might be triggered not only by a pointer,
13
19
// but a keyboard button as well. That's why ContextMenuEvent
14
20
// doesn't have a "currentPointer" property.
@@ -73,8 +79,7 @@ function addCircle(coord) {
73
79
callback : function ( ) {
74
80
map . removeObject ( circle ) ;
75
81
}
76
- } ) ,
77
- H . util . ContextItem . SEPARATOR
82
+ } )
78
83
) ;
79
84
} ) ;
80
85
@@ -109,4 +114,4 @@ var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));
109
114
var ui = H . ui . UI . createDefault ( map , defaultLayers ) ;
110
115
111
116
// Step 5: main logic
112
- addContextMenus ( map ) ;
117
+ addContextMenus ( map ) ;
File renamed without changes.
Original file line number Diff line number Diff line change 1
-
1
+
2
2
/**
3
3
* Switches the map language to simplified Chinese
4
4
*
5
5
* @param {H.Map } map A HERE Map instance within the application
6
6
* @pama {H.service.Platform} platform A stub class to access HERE services
7
7
*/
8
8
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 ) ;
21
15
22
16
// Display default UI components on the map and change default
23
17
// language to simplified Chinese.
@@ -63,4 +57,4 @@ window.addEventListener('resize', () => map.getViewPort().resize());
63
57
var behavior = new H . mapevents . Behavior ( new H . mapevents . MapEvents ( map ) ) ;
64
58
65
59
// Now use the map as required...
66
- switchMapLanguage ( map , platform ) ;
60
+ switchMapLanguage ( map , platform ) ;
Original file line number Diff line number Diff line change 57
57
"uid" : " map-multi-language-support" ,
58
58
"title" : " Multi-language support" ,
59
59
"shortDescription" : " Display a map with labels in a foreign language" ,
60
- "published" : false
60
+ "published" : true
61
61
},
62
62
{
63
63
"uid" : " map-scale-bar-changing-from-the-metric-system" ,
251
251
"title" : " Map Objects Event Delegation" ,
252
252
"shortDescription" : " Use event delegation on map objects" ,
253
253
"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
254
260
}
255
261
]
256
262
},
You can’t perform that action at this time.
0 commit comments