HTMLcopy
1
Map Zoom Event Info: <span id="text"></span>
2
<div id="container"></div>
CSScopy
6
1
html, body, #container {
2
width: 100%;
3
height: 100%;
4
margin: 0;
5
padding: 0;
6
}
JavaScriptcopy
x
1
anychart.onDocumentReady(function () {
2
// This sample uses 3rd party Proj4js JavaScript library to transform coordinates
3
// See https://docs.anychart.com/Maps/Map_Projections to learn more.
4
5
var data = [
6
{id: 'AU.CT', value: 15},
7
{id: 'AU.VI', value: 23},
8
{id: 'AU.WA', value: 86},
9
{id: 'AU.QL', value: 16},
10
{id: 'AU.NS', value: 32},
11
{id: 'AU.NT', value: 64},
12
{id: 'AU.TS', value: 28},
13
{id: 'AU.SA', value: 45}
14
];
15
16
var chart = anychart.map();
17
chart.width('100%').height('95%');
18
chart.geoData(anychart.maps.australia);
19
chart.title('Zoom map');
20
21
var series = chart.choropleth(data);
22
23
// Set event type to start the zoom
24
chart.listen('zoomStart', function(e) {
25
series.fill('#9CCC65');
26
document.getElementById("text").innerHTML = "zoom started";
27
});
28
29
// Set event type to finish the zoom
30
chart.listen('zoomEnd', function(e) {
31
series.fill('#ff7f24');
32
document.getElementById("text").innerHTML = "zoom finished";
33
chart.title('Zoom level ' + chart.getZoomLevel().toFixed().toString());
34
});
35
36
var zoom = anychart.ui.zoom();
37
zoom.target(chart);
38
39
chart.container('container');
40
chart.draw();
41
42
zoom.render(chart);
43
});