This repository was archived by the owner on Jul 30, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathannotation.tsx
More file actions
140 lines (138 loc) · 6.1 KB
/
annotation.tsx
File metadata and controls
140 lines (138 loc) · 6.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
/**
* Projection sample
*/
import * as React from "react";
import * as ReactDOM from "react-dom";
import { MapAjax } from '@syncfusion/ej2-maps';
import {
MapsComponent, Inject, ILoadedEventArgs, MapsTheme, LayersDirective, LayerDirective,
ProjectionType, Annotations, Marker, MarkersDirective, MarkerDirective
} from '@syncfusion/ej2-react-maps';
import { Browser } from '@syncfusion/ej2-base';
import { SampleBase } from '../common/sample-base';
const SAMPLE_CSS = `
.control-fluid {
padding: 0px !important;
}
#annotation {
color: #DDDDDD;
font-size: 12px;
font-family: Roboto;
background: #3E464C;
margin: 20px;
padding: 10px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
width: 300px;
-moz-box-shadow: 0px 2px 5px #666;
-webkit-box-shadow: 0px 2px 5px #666;
box-shadow: 0px 2px 5px #666;
}
.country-label {
color: white;
font-size: 25px;
}`;
export class AnnotationMaps extends SampleBase<{}, {}> {
private mapInstance: MapsComponent;
render() {
return (
<div className='control-pane'>
<style>
{SAMPLE_CSS}
</style>
<div className='control-section row'>
<MapsComponent id="maps" loaded={this.onMapsLoad.bind(this)} load={this.load} ref={m => this.mapInstance = m}
zoomSettings={{
enable: false
}}
annotations={[
{
content: '#maps-annotation',
x: '0%', y: '70%'
}, {
content: '#compass-maps',
x: '85%', y: '5%'
}
]}
>
<Inject services={[Annotations, Marker]} />
<LayersDirective>
<LayerDirective shapeData= {new MapAjax(location.origin + location.pathname + 'src/maps/map-data/africa-continent.json')}
shapePropertyPath='name'
shapeDataPath='name'
shapeSettings={{
fill: 'url(#grad1)'
}}
>
<MarkersDirective>
<MarkerDirective
visible={true} animationDuration={1}
template='<h3 style="color:white">{{:name}}</h3>'
dataSource={[{
name: 'Africa', latitude: 13.97274101999902, longitude: 20.390625
}]}
>
</MarkerDirective>
</MarkersDirective>
</LayerDirective>
</LayersDirective>
</MapsComponent>
</div>
<svg height="150" width="400">
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style={{stopColor: '#C5494B', stopOpacity: '1' }} />
<stop offset="100%" style={{ stopColor: '#4C134F', stopOpacity: '1' }} />
</linearGradient>
</defs>
</svg>
<div id="maps-annotation" style={{ display: 'none'}}>
<div id="annotation">
<div style={{marginLeft: '10px', fontsize:'13px' ,fontweight:500}}>
<h5 style={{ marginLeft: '40px' }}>Facts about Africa</h5>
</div>
<hr />
<div>
<ul style={{ listStyleType: 'disc' }}>
<li>Africa is the second largest and second most populated continent in the world.</li>
<li style={{paddingtop:'5px'}}>Africa has 54 sovereign states and 10 non-sovereign territories.</li>
<li style={{paddingtop:'5px'}}>Algeria is the largest country in Africa, where as Mayotte is the smallest.</li>
</ul>
</div>
</div>
</div>
<div id="compass-maps" style={{ display: 'none' }}>
<img src="src/maps/images/compass.svg" height="75px" width="75px"/>
</div>
<div style={{float: 'right', marginright: '10px'}}>Source:
<a href="https://en.wikipedia.org/wiki/Africa" target="_blank">en.wikipedia.org</a>
</div>
<div id="action-description">
<p>
This sample depicts the facts about Africa in an annotation. The shape of Africa is filled with gradient color.
</p>
</div>
<div id="description">
<p>
In this example, you can see how to render a map with the provided GeoJSON data. Group of shapes can be combined to form a layer of the map. You can bind the desired colors from the data source to the map shapes. The marker template is used to display the names for shapes. Legend is enabled in this example to represent each continent.
</p>
<br/>
<p style={{fontWeight: 500}}>Injecting Module</p>
<p>
Maps component features are segregated into individual feature-wise modules. To use an annotation, inject the Annotations module using the Maps.Inject(Annotations) method.
</p>
</div>
</div>
)
}
public onMapsLoad(args: ILoadedEventArgs): void {
let maps: Element = document.getElementById('maps');
maps.setAttribute('title', '');
};
public load(args: ILoadedEventArgs): void {
let selectedTheme: string = location.hash.split('/')[1];
selectedTheme = selectedTheme ? selectedTheme : 'Material';
args.maps.theme = (selectedTheme.charAt(0).toUpperCase() + selectedTheme.slice(1)) as MapsTheme;
};
}