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 pathmarker-template.tsx
More file actions
143 lines (142 loc) · 8.28 KB
/
marker-template.tsx
File metadata and controls
143 lines (142 loc) · 8.28 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
141
142
143
/**
* 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,
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;
}`;
let marker: object[] = [
{weather: 'clear', Name: 'Perth', latitude: -31.950527, longitude: 115.860457, Temperature: 31.6 },
{weather: 'clouds', Name: 'Adelaide', latitude: -34.928499, longitude: 138.600746, Temperature: 29 },
{weather: 'clear', Name: 'Townsville', latitude: -19.2589635, longitude: 146.8169483, Temperature: 31.3 },
{weather: 'rain', Name: 'Sydney', latitude: -33.868820, longitude: 151.209296, Temperature: 26.4 },
{weather: 'clear', Name: 'Alice Springs', latitude: -23.698042, longitude: 133.880747, Temperature: 36.4 },
{weather: 'clouds', Name: 'Brisbane', latitude: -27.469771, longitude: 153.025124, Temperature: 29.1 }
];
export class MarkerTemplateMaps extends SampleBase<{}, {}> {
private mapInstance: MapsComponent;
private change(): void {
}
render() {
return (
<div className='control-pane'>
<style>
{SAMPLE_CSS}
</style>
<div className='control-section row'>
<div className='col-md-12'>
<MapsComponent id="maps" loaded={this.onMapsLoad.bind(this)} load={this.load} ref={m => this.mapInstance = m}
zoomSettings={{
enable: false
}}
titleSettings={{
text: ' Australia cities weather details',
textStyle: {
size: '16px'
}
}}
>
<Inject services={[Marker]} />
<LayersDirective>
<LayerDirective shapeData={new MapAjax(location.origin + location.pathname + 'src/maps/map-data/australia.json')}
tooltipSettings={{
visible: false
}}
shapeSettings={{
autofill: true,
palette: ['#E2B247', '#88DB46', '#42C4E2', '#C08AF8', '#52BACC', '#F4CE2F', '#6986ED'],
border: {
width: 0.5,
color: 'white'
},
}}
>
<MarkersDirective>
<MarkerDirective visible={true}
height={30}
width={30}
template='<div id="marker1"><img style="height:30px;width:30px;display:block; margin: auto;" src="src/maps/images/weather-clear.png"/><p>{{:Name}}:{{:Temperature}}°C</p></div>'
dataSource={[marker[0]]}
>
</MarkerDirective>
<MarkerDirective visible={true}
height={30}
width={30}
template='<div id="marker1"><img style="height:30px;width:30px;display:block; margin: auto;" src="src/maps/images/weather-clouds.png"/><p>{{:Name}}:{{:Temperature}}°C</p></div>'
dataSource={[marker[1]]}
>
</MarkerDirective>
<MarkerDirective visible={true}
height={30}
width={30}
template='<div id="marker1"><img style="height:30px;width:30px;display:block; margin: auto;" src="src/maps/images/weather-clear.png"/><p>{{:Name}}:{{:Temperature}}°C</p></div>'
dataSource={[marker[2]]}
>
</MarkerDirective>
<MarkerDirective visible={true}
height={30}
width={30}
template='<div id="marker1"><img style="height:30px;width:30px;display:block; margin: auto;" src="src/maps/images/weather-rain.png"/><p>{{:Name}}:{{:Temperature}}°C</p></div>'
dataSource={[marker[3]]}
>
</MarkerDirective>
<MarkerDirective visible={true}
height={30}
width={30}
template='<div id="marker1"><img style="height:30px;width:30px;display:block; margin: auto;" src="src/maps/images/weather-clear.png"/><p>{{:Name}}:{{:Temperature}}°C</p></div>'
dataSource={[marker[4]]}
>
</MarkerDirective>
<MarkerDirective visible={true}
height={30}
width={30}
template='<div id="marker1"><img style="height:30px;width:30px;display:block; margin: auto;" src="src/maps/images/weather-clouds.png"/><p>{{:Name}}:{{:Temperature}}°C</p></div>'
dataSource={[marker[5]]}
>
</MarkerDirective>
</MarkersDirective>
</LayerDirective>
</LayersDirective>
</MapsComponent>
</div>
<div style={{float: 'right', marginright: '10px'}}>Source:
<a href="http://www.bom.gov.au/calendar/annual/climate.shtml" target="_blank">www.bom.gov.au</a>
</div>
</div>
<div id="action-description">
<p>
This sample indicates the temperature of various cities of Australia in marker templates.
</p>
</div>
<div id="description">
<p>
In this example, you can see how to place a template as a marker in the map. Any custom HTML elements can be used as a marker. You can use the autoFill property in the shapeSettings to apply the default palette colors to the shapes.
</p>
<br/>
<p style={{fontweight: 500}}>Injecting Module</p>
<p>
Maps component features are segregated into individual feature-wise modules. To use a marker template, inject the Marker module using the Maps.Inject(Marker) 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;
};
}