Search results

Annotations

Annotations are used to mark the specific area of interest in the map area with texts, shapes, or images. You can add any number of annotations to the maps.

Annotation

By using the content property of annotation object, you can either specify the id of an element or specify the code to create a new element that needs to be displayed in the gauge area.

<script id='annotation' type="text/x-template">
   <div id='template'>
       <img src='src/maps/images/flight.png'>
   </div>
</script>
import { Maps, Annotations } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
Maps.Inject(Annotations);

let maps: Maps = new Maps({
        annotations: [
            {
                content: '#annotation',
                x: '0%', y: '50%'
            }
        ],
        layers: [
            {
                shapeData: world_map,
            }
        ]
    });
    maps.appendTo('#element');

Annotation Customization

Changing the z-order

You can change the z-order of an annotation element using the zIndex property.

Source
Preview
index.ts
index.html
index.css
import { Maps } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
let map: Maps = new Maps({
   annotations: [
            {
                content: '<div id="first"><h1>Maps</h1></div>',
                x: '0%', y: '50%',
                zIndex: '-1'
            }
   ],
   layers: [
        {
             shapeData: world_map
        }
    ]
}, '#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="systemjs.config.js"></script>
</head>

<body>
    <div id='loader'>Loading....</div>
    <div id='container' style="height: 500px; width: 500px">
        <div id='element'></div>
    </div>
</body>

</html>

Positioning of Annotation

You can place an annotation anywhere in gauge area by specifying pixel values to the x and y properties.

Source
Preview
index.ts
index.html
index.css
import { Maps } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
let map: Maps = new Maps({
   annotations: [
            {
                content: '<div id="first"><h1>Maps</h1></div>',
                x: '20%', y: '50%',
                zIndex: '-1'
            }
   ],
   layers: [
        {
             shapeData: world_map
        }
    ]
}, '#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="systemjs.config.js"></script>
</head>

<body>
    <div id='loader'>Loading....</div>
    <div id='container' style="height: 500px; width: 500px">
        <div id='element'></div>
    </div>
</body>

</html>

Alignment of Annotation

You can align annotations using the horizontalAlignment and verticalAlignment properties.

Source
Preview
index.ts
index.html
index.css
import { Maps } from '@syncfusion/ej2-maps';
import { world_map } from './world-map.ts';
let map: Maps = new Maps({
   annotations: [
            {
                content: '<div id="first"><h1>Maps</h1></div>',
                verticalAlignment: 'Center',
                horizontalAlignment: 'Center',
                x: '20%', y: '50%',
                zIndex: '-1'
            }
   ],
   layers: [
        {
             shapeData: world_map
        }
    ]
}, '#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="systemjs.config.js"></script>
</head>

<body>
    <div id='loader'>Loading....</div>
    <div id='container' style="height: 500px; width: 500px">
        <div id='element'></div>
    </div>
</body>

</html>