HTMLcopy
1
<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
3
// This sample uses 3rd party proj4 component
4
// that makes it possible to set coordinates
5
// for the points and labels on the map and
6
// required for custom projections and grid labels formatting.
7
// See https://docs.anychart.com/Maps/Map_Projections
8
9
// set the stage as a container
10
stage = anychart.graphics.create("container");
11
12
// set the data
13
var data = [
14
{"id": "AU.CT", value: 15},
15
{"id": "AU.VI", value: 23},
16
{"id": "AU.WA", value: 86},
17
{"id": "AU.QL", value: 16},
18
{"id": "AU.NS", value: 32},
19
{"id": "AU.NT", value: 64},
20
{"id": "AU.TS", value: 28},
21
{"id": "AU.SA", value: 45}
22
];
23
24
// create the map
25
var map = anychart.map();
26
map.geoData(anychart.maps.australia);
27
28
// disable all interactivity
29
map.interactivity(false);
30
31
// set the map title
32
map.title("Zoom map to a point");
33
34
// create the series
35
map.choropleth(data);
36
37
// set the container
38
map.container(stage);
39
40
// draw a map
41
map.draw();
42
43
// set zoom
44
var clicked = true;
45
map.listen("click", function(evt) {
46
if (clicked) {
47
map.zoomTo(3, evt.clientX, evt.clientY);
48
}
49
else {
50
map.zoomTo(0, evt.clientX, evt.clientY);
51
}
52
clicked = !clicked;
53
});
54
55
});