Search results

User Interactions

Options like zooming, panning, single click and double click, highlight and map selection enables the effective interaction on Map elements.

Zooming

The zooming feature enables you to zoom in and out the Map to show in-depth information. It is controlled by the zoomFactor property of the zoomSettings of the map. When the zoomFactor is increased, the Map is zoomed in. When the zoomFactor is decreased, then the Map is zoomed out.

Enable Zooming

To enable the zooming feature, set the zoomSettings.enable as true in maps. Zooming feature needs the Zoom module injection to perform zooming actions, use module injection to inject zoom into Maps by using Maps.Inject(Zoom) method.

Various type of zooming

Zooming can be performed by various types. click zooming, double click zooming, toolbar zooming rectangular zooming, mouse wheel zooming and pinch zooming.

Refer the API links for Zooming.

import { usmap } from 'usa.ts';
import { Maps, Zoom } from '@syncfusion/ej2-maps';
Maps.Inject(Zoom);
let map: Maps = new Maps({
    zoomSettings: {
        enable: true,
    },
    layers: [{
        shapeData: usmap,
    }]
});
map.appendTo('#element');

Selection

Each shape in the Map can be selected and deselected during interaction with the shapes.

By tapping on the specific legend, the shapes which are bounded to the selected legend is also selected and vice versa.

The layer selectionSettings.fill property is used to change the selected layer shape color. The selectionSettings.border.color and selectionSettings.border.width properties are used to customize the selected shape border.

You can select the shape by tapping the shape. The Single selection is enabled by the selectionSettings.enable property of shape layer. When selectionSettings.enable is set to false, the shapes cannot be selected.

Refer the API and code snippet for Selection.

Note: Selection is separate module, need to inject to work on Selection.

Source
Preview
index.html
index.css
<!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="//cdn.syncfusion.com/ej2/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    
    <div id="container" style="height: 500px; width: 500px">
        <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>

Highlight

Each shape in the Map can be highlighted during mouse over on the shapes.

Hovering on the specific legend, the shapes which are bounded to the selected legend is also highlighted and vice versa.

The layer highlightSettings.fill property is used to change the highlighted layer shape color. The highlightSettings.border.color and highlightSettings.border.width properties are used to customize the highlighted shape border.

You can highlight the shape by mouse over on the shape. The highlight is enabled by the highlightSettings.enable property of shape layer. When highlightSettings.enable is set to false, the shapes cannot be highlighted.

Note: Highlight is separate module, need to inject to work on Highlight.

Refer the API and code snippet for Highlight.

Source
Preview
index.html
index.css
<!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="//cdn.syncfusion.com/ej2/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    
    <div id="container" style="height: 500px; width: 500px">
        <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>

Tooltip

Tooltip used to get more information about layer or bubble or marker on mouse over or touch end event performing on that. Tooltip is a separate module, So it needs module injection to work maps tooltip. Using Maps.Inject(MapsTooltip) method you can inject maps tooltip module into maps.

Tooltip can be enabled separately for layer or bubble or marker by using tooltipSettings.visible as true. Tooltip valuePath value need to set to display dataSource which field as tooltip text. Below code snippet illustrate the tooltip enabled for layer to show shape data name field.

Refer the API for Tooltip feature.

Step: 1 Import the usmap geo json data from already created WorldMap.ts file and assign to shapeData.

Step: 2 Import MapsTooltip module from ej2-maps package and Inject to Maps.

Step: 3 Enable tooltip for layer using tooltipSettings.visible as true and bind valuePath value as ‘name’.

Source
Preview
index.html
index.css
<!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="//cdn.syncfusion.com/ej2/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    
    <div id="container" style="height: 500px; width: 500px">
        <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>

See Also