The width and height of the Maps can be set using the width and height properties in Maps. Percentage or pixel values can be used for the height and width values.
import { Maps } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
let map: Maps = new Maps({
height: '200px',
width: '500px',
layers: [{
shapeData: world_map,
shapeSettings: {
autofill: true
}
}]
});
map.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Maps</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="world-map.js"></script>
<script src="usa.js"></script>
<script src="data.js"></script>
<script src="california.js"></script>
<script src="texas.js"></script>
<script src="africa_continent.js"></script>
<script src="africa.js"></script>
<script src="cluster.js"></script>
<script src="markerdata.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container' style="height: 500px; width: 700px">
<div id='element'></div>
</div>
<svg height="150" width="400">
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:#C5494B;stop-opacity:1" />
<stop offset="100%" style="stop-color:#4C134F;stop-opacity:1" />
</linearGradient>
</defs>
</svg>
<!-- annotation content -->
<div id="maps-annotation" style="display: none;">
<div id="annotation">
<div>
<p style="margin-left:10px;font-size:13px;font-weight:500">Facts about Africa</p>
</div>
<hr style="margin-top:-3px;margin-bottom:10px;border:0.5px solid #DDDDDD">
<div>
<ul style="list-style-type:disc; margin-left:-20px;margin-bottom:2px; font-weight:400">
<li>Africa is the second largest and second most populated continent in the world.</li>
<li style="padding-top:5px;">Africa has 54 sovereign states and 10 non-sovereign territories.</li>
<li style="padding-top: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="templates/maps/how-to/annotation/compass.png" height="75px" width="75px">
</div>
<style>
#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;
}
</style>
</body>
</html>
The title for the Maps can be set using the titleSettings. It can be customized using the following properties.
import { Maps } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
let map: Maps = new Maps({
titleSettings: {
text: 'Maps Control',
textStyle: {
color: 'red',
fontStyle: 'italic',
fontWeight: 'regular',
fontFamily: 'arial',
size: '14px'
},
alignment: 'Center'
},
layers: [{
shapeData: world_map,
shapeSettings: {
autofill: true
}
}]
});
map.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Maps</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="world-map.js"></script>
<script src="usa.js"></script>
<script src="data.js"></script>
<script src="california.js"></script>
<script src="texas.js"></script>
<script src="africa_continent.js"></script>
<script src="africa.js"></script>
<script src="cluster.js"></script>
<script src="markerdata.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container' style="height: 500px; width: 700px">
<div id='element'></div>
</div>
<svg height="150" width="400">
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:#C5494B;stop-opacity:1" />
<stop offset="100%" style="stop-color:#4C134F;stop-opacity:1" />
</linearGradient>
</defs>
</svg>
<!-- annotation content -->
<div id="maps-annotation" style="display: none;">
<div id="annotation">
<div>
<p style="margin-left:10px;font-size:13px;font-weight:500">Facts about Africa</p>
</div>
<hr style="margin-top:-3px;margin-bottom:10px;border:0.5px solid #DDDDDD">
<div>
<ul style="list-style-type:disc; margin-left:-20px;margin-bottom:2px; font-weight:400">
<li>Africa is the second largest and second most populated continent in the world.</li>
<li style="padding-top:5px;">Africa has 54 sovereign states and 10 non-sovereign territories.</li>
<li style="padding-top: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="templates/maps/how-to/annotation/compass.png" height="75px" width="75px">
</div>
<style>
#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;
}
</style>
</body>
</html>
The Maps control supports following themes.
By default, the Maps are rendered by the Material theme. The theme of the Maps component is changed using the theme property.
import { Maps, MapsTheme } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
let map: Maps = new Maps({
layers: [{
shapeData: world_map,
shapeSettings: {
autofill: true,
}
}]
});
map.appendTo('#element');
document.getElementById('theme').onchange = () => {
var value = (<HTMLInputElement>document.getElementById('theme')).value;
map.theme= <MapsTheme>value;
map.refresh();
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Maps</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="world-map.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div class="col-lg-9 control-section">
<div id="container" align="center"></div>
</div>
<div class="col-lg-3 property-section">
<table id="property" title="Properties" style="width: 100%">
<tbody><tr style="height: 50px">
<td style="width: 60%">
<div>Projection Type</div>
</td>
<td style="width: 40%;">
<select name="theme" id="theme" style="margin-left: -25px">
<option value="Material">Material</option>
<option value="Fabric">Fabric</option>
<option value="Bootstrap">Bootstrap</option>
<option value="Highcontrast">Highcontrast</option>
<option value="MaterialDark">MaterialDark</option>
<option value="FabricDark">FabricDark</option>
<option value="BootstrapDark">BootstrapDark</option>
<option value="Bootstrap4">Bootstrap4</option>
</select>
</td>
</tr>
</tbody></table>
</div>
</body>
</html>
The following properties are available to customize the container in the Maps.
import { Maps } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
let map: Maps = new Maps({
background: '#CCD1D1',
border: {
color: 'green',
width: 2
},
margin: {
bottom: 10,
left: 20,
right: 20,
top: 10
},
layers: [{
shapeData: world_map,
shapeSettings: {
autofill: true
}
}]
});
map.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Maps</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="world-map.js"></script>
<script src="usa.js"></script>
<script src="data.js"></script>
<script src="california.js"></script>
<script src="texas.js"></script>
<script src="africa_continent.js"></script>
<script src="africa.js"></script>
<script src="cluster.js"></script>
<script src="markerdata.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container' style="height: 500px; width: 700px">
<div id='element'></div>
</div>
<svg height="150" width="400">
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:#C5494B;stop-opacity:1" />
<stop offset="100%" style="stop-color:#4C134F;stop-opacity:1" />
</linearGradient>
</defs>
</svg>
<!-- annotation content -->
<div id="maps-annotation" style="display: none;">
<div id="annotation">
<div>
<p style="margin-left:10px;font-size:13px;font-weight:500">Facts about Africa</p>
</div>
<hr style="margin-top:-3px;margin-bottom:10px;border:0.5px solid #DDDDDD">
<div>
<ul style="list-style-type:disc; margin-left:-20px;margin-bottom:2px; font-weight:400">
<li>Africa is the second largest and second most populated continent in the world.</li>
<li style="padding-top:5px;">Africa has 54 sovereign states and 10 non-sovereign territories.</li>
<li style="padding-top: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="templates/maps/how-to/annotation/compass.png" height="75px" width="75px">
</div>
<style>
#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;
}
</style>
</body>
</html>
By default, the background color of the shape maps is set as white. To modify the background color of the Maps area, the background property in the mapsArea is used. The border of the Maps area can be customized using the border property in the mapsArea.
import { Maps } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
let map: Maps = new Maps({
mapsArea: {
background: '#CCD1D1',
border: {
width: 2,
color: 'green'
}
},
layers: [{
shapeData: world_map,
shapeSettings: {
autofill: true
}
}]
});
map.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Maps</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="world-map.js"></script>
<script src="usa.js"></script>
<script src="data.js"></script>
<script src="california.js"></script>
<script src="texas.js"></script>
<script src="africa_continent.js"></script>
<script src="africa.js"></script>
<script src="cluster.js"></script>
<script src="markerdata.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container' style="height: 500px; width: 700px">
<div id='element'></div>
</div>
<svg height="150" width="400">
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:#C5494B;stop-opacity:1" />
<stop offset="100%" style="stop-color:#4C134F;stop-opacity:1" />
</linearGradient>
</defs>
</svg>
<!-- annotation content -->
<div id="maps-annotation" style="display: none;">
<div id="annotation">
<div>
<p style="margin-left:10px;font-size:13px;font-weight:500">Facts about Africa</p>
</div>
<hr style="margin-top:-3px;margin-bottom:10px;border:0.5px solid #DDDDDD">
<div>
<ul style="list-style-type:disc; margin-left:-20px;margin-bottom:2px; font-weight:400">
<li>Africa is the second largest and second most populated continent in the world.</li>
<li style="padding-top:5px;">Africa has 54 sovereign states and 10 non-sovereign territories.</li>
<li style="padding-top: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="templates/maps/how-to/annotation/compass.png" height="75px" width="75px">
</div>
<style>
#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;
}
</style>
</body>
</html>
The following properties are available in shapeSettings property to customize the shapes of the Maps component.
import { Maps } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
let map: Maps = new Maps({
layers: [{
shapeData: world_map,
shapeSettings: {
autofill: true,
palette: ['#33CCFF', '#FF0000', '#800000', '#FFFF00', '#808000'],
border: {
color: 'green',
width: 2
},
dashArray: '1',
opacity: 0.9
}
}]
});
map.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Maps</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="world-map.js"></script>
<script src="usa.js"></script>
<script src="data.js"></script>
<script src="california.js"></script>
<script src="texas.js"></script>
<script src="africa_continent.js"></script>
<script src="africa.js"></script>
<script src="cluster.js"></script>
<script src="markerdata.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container' style="height: 500px; width: 700px">
<div id='element'></div>
</div>
<svg height="150" width="400">
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:#C5494B;stop-opacity:1" />
<stop offset="100%" style="stop-color:#4C134F;stop-opacity:1" />
</linearGradient>
</defs>
</svg>
<!-- annotation content -->
<div id="maps-annotation" style="display: none;">
<div id="annotation">
<div>
<p style="margin-left:10px;font-size:13px;font-weight:500">Facts about Africa</p>
</div>
<hr style="margin-top:-3px;margin-bottom:10px;border:0.5px solid #DDDDDD">
<div>
<ul style="list-style-type:disc; margin-left:-20px;margin-bottom:2px; font-weight:400">
<li>Africa is the second largest and second most populated continent in the world.</li>
<li style="padding-top:5px;">Africa has 54 sovereign states and 10 non-sovereign territories.</li>
<li style="padding-top: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="templates/maps/how-to/annotation/compass.png" height="75px" width="75px">
</div>
<style>
#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;
}
</style>
</body>
</html>
The color for each shape in the Maps can be set using the colorValuePath property of shapeSettings. The value for the colorValuePath property is the field name from the data source of the shapeSettings which contains the color values.
import { Maps } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
let map: Maps = new Maps({
layers: [{
shapeData: world_map,
shapePropertyPath: 'continent',
shapeDataPath: 'continent',
dataSource: [
{ continent: "North America", color: '#71B081' },
{ continent: "South America", color: '#5A9A77' },
{ continent: "Africa", color: '#498770' },
{ continent: "Europe", color: '#39776C' },
{ continent: "Asia", color: '#266665' },
{ continent: "Oceania", color: '#124F5E' }
],
shapeSettings: {
colorValuePath: 'color'
}
}]
});
map.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Maps</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="world-map.js"></script>
<script src="usa.js"></script>
<script src="data.js"></script>
<script src="california.js"></script>
<script src="texas.js"></script>
<script src="africa_continent.js"></script>
<script src="africa.js"></script>
<script src="cluster.js"></script>
<script src="markerdata.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container' style="height: 500px; width: 700px">
<div id='element'></div>
</div>
<svg height="150" width="400">
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:#C5494B;stop-opacity:1" />
<stop offset="100%" style="stop-color:#4C134F;stop-opacity:1" />
</linearGradient>
</defs>
</svg>
<!-- annotation content -->
<div id="maps-annotation" style="display: none;">
<div id="annotation">
<div>
<p style="margin-left:10px;font-size:13px;font-weight:500">Facts about Africa</p>
</div>
<hr style="margin-top:-3px;margin-bottom:10px;border:0.5px solid #DDDDDD">
<div>
<ul style="list-style-type:disc; margin-left:-20px;margin-bottom:2px; font-weight:400">
<li>Africa is the second largest and second most populated continent in the world.</li>
<li style="padding-top:5px;">Africa has 54 sovereign states and 10 non-sovereign territories.</li>
<li style="padding-top: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="templates/maps/how-to/annotation/compass.png" height="75px" width="75px">
</div>
<style>
#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;
}
</style>
</body>
</html>
The border of each shape in the Maps can be customized using the borderColorValuePath and borderColorValuePath properties to modify the color and width of the border respectively. The field name in the data source of the layer which contains the color and width values must be set in the borderColorValuePath and borderWidthValuePath properties. If the values of borderWidthValuePath and borderColorValuePath do not match with the field name from the data source, then the color and width of the border will be applied to the shapes using the border property in the shapeSettings.
import { Maps } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
let map: Maps = new Maps({
layers: [{
shapeData: world_map,
shapePropertyPath: 'continent',
shapeDataPath: 'continent',
dataSource: [
{ continent: "North America", color: '#71B081', borderColor: '#CCFFE5', width: 2 },
{ continent: "South America", color: '#5A9A77', borderColor: 'red', width: 2 },
{ continent: "Africa", color: '#498770', borderColor: '#FFCC99', width: 2 },
{ continent: "Europe", color: '#39776C', borderColor: '#66B2FF', width: 2 },
{ continent: "Asia", color: '#266665', borderColor: '#999900', width: 2 },
{ continent: "Oceania", color: '#124F5E', borderColor: 'blue', width: 2 }
],
shapeSettings: {
borderColorValuePath: 'borderColor',
borderWidthValuePath: 'width',
colorValuePath: 'color'
}
}]
});
map.appendTo('#element');
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Maps</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="world-map.js"></script>
<script src="usa.js"></script>
<script src="data.js"></script>
<script src="california.js"></script>
<script src="texas.js"></script>
<script src="africa_continent.js"></script>
<script src="africa.js"></script>
<script src="cluster.js"></script>
<script src="markerdata.js"></script>
<script src="systemjs.config.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div id='container' style="height: 500px; width: 700px">
<div id='element'></div>
</div>
<svg height="150" width="400">
<defs>
<linearGradient id="grad1" x1="0%" y1="0%" x2="0%" y2="100%">
<stop offset="0%" style="stop-color:#C5494B;stop-opacity:1" />
<stop offset="100%" style="stop-color:#4C134F;stop-opacity:1" />
</linearGradient>
</defs>
</svg>
<!-- annotation content -->
<div id="maps-annotation" style="display: none;">
<div id="annotation">
<div>
<p style="margin-left:10px;font-size:13px;font-weight:500">Facts about Africa</p>
</div>
<hr style="margin-top:-3px;margin-bottom:10px;border:0.5px solid #DDDDDD">
<div>
<ul style="list-style-type:disc; margin-left:-20px;margin-bottom:2px; font-weight:400">
<li>Africa is the second largest and second most populated continent in the world.</li>
<li style="padding-top:5px;">Africa has 54 sovereign states and 10 non-sovereign territories.</li>
<li style="padding-top: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="templates/maps/how-to/annotation/compass.png" height="75px" width="75px">
</div>
<style>
#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;
}
</style>
</body>
</html>
The Maps control supports the following projection types:
By default, the Maps are rendered by the Mercator projection type in which the Maps are rendered based on the coordinates. So, the Maps is not stretched. To change the type of projection in the Maps, the projectionType property is used.
import { Maps, ProjectionType } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
import { projectionData } from './projection-data.ts';
let map: Maps = new Maps({
projectionType: 'Mercator',
layers: [{
shapeData: world_map,
shapeDataPath: 'Country',
shapePropertyPath: 'name',
dataSource: projectionData,
tooltipSettings: {
visible: true,
valuePath: 'Country',
},
shapeSettings: {
fill: '#E5E5E5',
colorMapping: [
{
value: 'Permanent',
color: '#EDB46F'
},
{
color: '#F1931B',
value: 'Non-Permanent'
}
],
colorValuePath: 'Membership'
}
}]
});
map.appendTo('#container');
document.getElementById('projectiontype').onchange = function(){
let ele: HTMLSelectElement = (<HTMLSelectElement>document.getElementById('projectiontype'))
map.projectionType = <ProjectionType>ele.value;
map.refresh();
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>EJ2 Maps</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Typescript UI Controls" />
<meta name="author" content="Syncfusion" />
<link href="index.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/systemjs/0.19.38/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="projection-data.js"></script>
<script src="world-map.js"></script>
</head>
<body>
<div id='loader'>Loading....</div>
<div class="col-lg-9 control-section">
<div id="container" align="center"></div>
</div>
<div class="col-lg-3 property-section">
<table id="property" title="Properties" style="width: 100%">
<tbody><tr style="height: 50px">
<td style="width: 60%">
<div>Projection Type</div>
</td>
<td style="width: 40%;">
<select name="projectionType" id="projectiontype" style="margin-left: -25px">
<option value="Mercator">Mercator</option>
<option value="Equirectangular">Equirectangular</option>
<option value="Miller">Miller</option>
<option value="Eckert3">Eckert3</option>
<option value="Eckert5">Eckert5</option>
<option value="Eckert6">Eckert6</option>
<option value="Winkel3">Winkel3</option>
<option value="AitOff">AitOff</option>
</select>
</td>
</tr>
</tbody></table>
</div>
</body>
</html>