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
var map = anychart.map();
37
map.geoData(anychart.maps.united_states_of_america);
38
39
// Creates the marker series
40
var series_acme = map.marker(data_ACME);
41
series_acme.name("ACME Corp. branch");
42
var series_citrus = map.marker(data_CITRUS);
43
series_citrus.name("CITRUS Corp. branch");
44
45
// format the tooltips
46
map.tooltip().titleFormat("{%seriesName}");
47
map.tooltip().format("Yearly profit: ${%value}m");
48
49
// turn off labels
50
map.labels(false);
51
52
// set the colors of the CITRUS series
53
series_citrus.stroke("green");
54
series_citrus.fill("gold");
55
56
// set the size of CITRUS markers
57
series_citrus.normal().size(8);
58
series_citrus.hovered().size(10);
59
series_citrus.selected().size(10);
60
61
// set the size of ACME markers
62
series_acme.normal().size(4);
63
series_acme.hovered().size(6);
64
series_acme.selected().size(6);
65
66
// set the type of CITRUS markers
67
series_citrus.normal().type("star4");
68
series_citrus.hovered().type("star5");
69
series_citrus.selected().type("star6");
70
71
map.title("Formatting the marker types");
72
73
map.container("container");
74
map.draw();
75
});