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
var map = anychart.map();
10
var data = [
11
{'id': 'AU.WA'},
12
{'id': 'AU.JB'},
13
{'id': 'AU.NS'},
14
{'id': 'AU.VI'},
15
{'id': 'AU.NT'},
16
{'id': 'AU.TS'},
17
{'id': 'AU.CT'},
18
{'id': 'AU.SA'},
19
{'id': 'AU.QL'}
20
];
21
22
map.geoData(anychart.maps.australia);
23
24
// set the title and its preferences
25
map.title('Getting data from GeoJSON');
26
27
// set the series
28
var series = map.choropleth(data);
29
// enable labels
30
labels = series.labels();
31
labels.enabled(true);
32
33
// format labels text
34
labels.format(function () {
35
// Gets point source region properties.
36
var properties = this.regionProperties;
37
return properties["postal"] + " (" + properties["type"] + ")";
38
});
39
40
// set the container
41
map.container('container');
42
map.draw();
43
});