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
// create the dataset of points that are defined by latitude and longtitude values
10
var dataSet_lat_long = [
11
{lat: -25.75, long: 122.18, name: "ACME Corp. branch No. 1", value: 321},
12
{lat: -18.50, long: 135.24, name: "ACME Corp. branch No. 2", value: 293},
13
{lat: -23.12, long: 148.62, name: "ACME Corp. branch No. 3", value: 312},
14
{lat: -17.89, long: 145.09, name: "ACME Corp. branch No. 4", value: 198},
15
{lat: -33.28, long: 135.58, name: "ACME Corp. branch No. 5", value: 309},
16
{lat: -31.21, long: 116.44, name: "ACME Corp. branch No. 6", value: 215},
17
{lat: -32.26, long: 151.44, name: "ACME Corp. branch No. 7", value: 219},
18
{lat: -25.63, long: 152.37, name: "ACME Corp. branch No. 8", value: 179}
19
];
20
21
// create the dataset of points that are defined by the region id
22
var dataSet_id = [
23
{id: "AU.NS", farms: 240},
24
{id: "AU.NT", farms: 202},
25
{id: "AU.WA", farms: 193},
26
{id: "AU.SA", farms: 196},
27
{id: "AU.VI", farms: 48},
28
{id: "AU.TS", farms: 13},
29
{id: "AU.QL", farms: 136}
30
];
31
32
var map = anychart.map();
33
map.geoData(anychart.maps.australia);
34
35
// Creates the marker series
36
var series_lat_long = map.marker(dataSet_lat_long);
37
var series_id = map.marker(dataSet_id);
38
39
// format the tooltips of the lat_long series
40
series_lat_long.tooltip().titleFormat("{%name}");
41
series_lat_long.tooltip().format("Yearly profit: ${%value}m");
42
43
// format the tooltips of the id-defined series
44
series_id.tooltip().titleFormat("{%name}");
45
series_id.tooltip().format("Sheep farms: {%farms}");
46
47
//format the labels of the id-defined series
48
series_id.labels().format("{%name}");
49
50
// format the labels of the series defined by latitude and longitude
51
series_lat_long.labels(false);
52
53
// turn off the labels of the second series for creating less chaos in a map
54
series_lat_long.hovered().labels(false);
55
series_lat_long.selected().labels(false);
56
57
// hovered and selected labels
58
series_id.hovered().labels().fontColor("black");
59
series_id.selected().labels().fontColor("red");
60
61
// change the color of the lat-long series
62
series_lat_long.stroke("green");
63
series_lat_long.fill("gold");
64
65
// make the markers of the series with id bigger
66
series_id.size(10);
67
series_id.hovered().size(10);
68
69
map.title("Series of both types on one map");
70
71
map.container("container");
72
map.draw();
73
});