Having trouble getting help?
Contact Support
Contact Support
Drilldown in EJ2 JavaScript Maps control
27 Apr 20235 minutes to read
By clicking a continent, all the countries available in that continent can be viewed using the drill-down feature. For example, the countries in the Africa
continent have been showcased here. To showcase all the countries in Africa
continent by clicking the shapeSelected
event as mentioned in the following example.
var map = new ej.maps.Maps({
shapeSelected: function(args) {
var shape =(args.shapeData).continent;
if (shape === 'Africa') {
map.baseLayerIndex = 1;
map.refresh();
}
},
layers: [
{
shapeData: world_map,
shapePropertyPath: 'continent',
shapeDataPath: 'continent',
dataSource:default_data,
shapeSettings: {
colorValuePath: 'drillColor'
},
markerSettings: [{
visible: true,
template: '<div id="marker3" class="markerTemplate">Africa' +
'</div>',
dataSource: [
{ latitude: 10.97274101999902, longitude: 16.390625 }
],
animationDuration: 0
}
]
},
{
shapeData: africa,
shapeSettings: {
fill: '#80306A'
},
highlightSettings: {
enable: true,
fill: '#80306A'
}
}
]
});
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="world-map.js"></script>
<script src="africa.js"></script>
<script src="data.js"></script>
<script src="https://cdn.syncfusion.com/ej2/29.1.33/dist/ej2.min.js" type="text/javascript"></script>
<script src="https://cdn.syncfusion.com/ej2/syncfusion-helper.js" type ="text/javascript"></script>
</head>
<body>
<div id="container" style="height: 500px; width: 700px">
<div id="element"></div>
</div>
<script>
var ele = document.getElementById('container');
if (ele) {
ele.style.visibility = "visible";
}
</script>
<script src="index.js" type="text/javascript"></script>
</body>
</html>
<div id="mapdrilldown"></div>
<style>
.markerTemplate {
font-size: 12px;
color: white;
text-shadow: 0px 1px 1px black;
font-weight: 500
}
.markerTemplate {
height: 30px;
width: 30px;
display: block;
margin: auto;
}
</style>