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 data_ACME = [
11
{lat: 33.75, long: -112.18, name: "Stepford", value: 321},
12
{lat: 33.79, long: -101.52, name: "Metropolis", value: 293},
13
{lat: 26.12, long: -113.62, name: "Haddonfield", value: 312},
14
{lat: 37.89, long: -105.09, name: "Marlberry", value: 198},
15
{lat: 40.20, long: -84.28, name: "Sunnydale", value: 309},
16
{lat: 39.44, long: -116.04, name: "Landmark", value: 215},
17
{lat: 46.31, long: -99.88, name: "Springfield", value: 219},
18
{lat: 27.63, long: -82.37, name: "Vice City", value: 179}
19
];
20
21
var data_CITRUS = [
22
{lat: 45.75, long: -88.18, name: "Bas", value: 221},
23
{lat: 43.44, long: -70.85, name: "Hillwood", value: 203},
24
{lat: 41.46, long: -99.61, name: "Shermer", value: 162},
25
{lat: 38.14, long: -90.40, name: "Venusville", value: 98},
26
{lat: 29.28, long: -100.58, name: "South Park", value: 109},
27
{lat: 47.38, long: -120.06, name: "Heavensent", value: 215},
28
{lat: 44.50, long: -106.8, name: "Wellsville", value: 201},
29
{lat: 44.63, long: -122.37, name: "Whoville", value: 138},
30
{lat: 30.66, long: -88.15, name: "Bedrock", value: 210},
31
{lat: 35.21, long: -116.44, name: "Bluffington", value: 195},
32
{lat: 24.76, long: -151.44, name: "Primwille", value: 112},
33
{lat: 34.51, long: -96.65, name: "Hillywood", value: 89}
34
];
35
36
37
var map = anychart.map();
38
map.geoData(anychart.maps.united_states_of_america);
39
40
// Creates the marker series
41
var series_acme = map.marker(data_ACME);
42
series_acme.name("ACME Corp. branch");
43
var series_citrus = map.marker(data_CITRUS);
44
series_citrus.name("CITRUS Corp. branch");
45
46
// format the tooltips
47
map.tooltip().titleFormat("{%seriesName}");
48
map.tooltip().format("Yearly profit: ${%value}m");
49
50
// turn off labels
51
map.labels(false);
52
53
// set the colors of the CITRUS series
54
series_citrus.normal().fill("#ef6c00", 0.3);
55
series_citrus.hovered().fill("#ef6c00", 0.1);
56
series_citrus.selected().fill("#ef6c00", 0.5);
57
series_citrus.normal().stroke("#ef6c00");
58
series_citrus.hovered().stroke("#ef6c00", 2);
59
series_citrus.selected().stroke("#ef6c00", 2);
60
61
// set the size of markers of the CITRUS series
62
series_citrus.normal().size(8);
63
series_citrus.hovered().size(10);
64
series_citrus.selected().size(10);
65
66
map.title("Formatting the series colors");
67
68
map.container("container");
69
map.draw();
70
});