HTMLcopy
1
<div id="container"></div>
CSScopy
8
1
html,
2
body,
3
#container {
4
width: 100%;
5
height: 100%;
6
margin: 0;
7
padding: 0;
8
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// create map chart
3
var map = anychart.map();
4
5
// set map title
6
map.title('Default map projection is WSG84');
7
8
// set crs change animation duration
9
map.crsAnimation().duration(300);
10
11
// set map geo data
12
map.geoData('anychart.maps.world_source');
13
14
// set container id for the map
15
map.container('container');
16
// initiate map drawing
17
map.draw();
18
19
// list of available projections
20
// see https://api.anychart.com/anychart.enums.MapProjections for details
21
var projectionsList = [
22
'bonne',
23
'eckert1',
24
'eckert3',
25
'equirectangular',
26
'fahey',
27
'hammer',
28
'aitoff',
29
'mercator',
30
'robinson',
31
'wagner6',
32
'wsg84',
33
'august'
34
];
35
36
// util vars for projection update cycle
37
var index = 0;
38
var count = projectionsList.length;
39
40
// set timer to change map projection every 500 mc
41
setInterval(function () {
42
// loop projection index
43
if (index >= count) index %= count;
44
45
// take projection name from the list
46
var projection = projectionsList[index];
47
48
// update map title
49
map.title('Map projection: ' + projection);
50
51
// set projection to the map
52
map.crs(projection);
53
54
index++;
55
}, 1500);
56
});