Custom callback function after route calculation
<!DOCTYPE html>
<html>
<head>
<title>Custom callback function after route calculation</title>
<script src="https://maps.cercalia.com/maps/loader.js?key=YOUR_API_KEY&v=5&lang=en&theme=1976d2"></script>
</head>
<body>
<div id="map" class="map"></div>
<script>
var map;
document.addEventListener('cercalia-ready', function() {
map = new cercalia.Map({
target: 'map'
});
calculateExampleRoute();
});
function calculateExampleRoute() {
var routingMap = map.getMapRouting();
var origin = new cercalia.LonLat(2.1589900, 41.3887900);
var destination = new cercalia.LonLat(-3.7025600, 40.4165000);
routingMap.disableAutoZoom(true);
routingMap.setCustomCallbackFunction(function() {
var notification = new cercalia.Notification('Route calculated', cercalia.Notification.Severity.WARNING);
notification.display(map);
});
routingMap.setRoutingStep(cercalia.MapRouting.MarkerType.ORIGIN, origin);
routingMap.setRoutingStep(cercalia.MapRouting.MarkerType.DESTINATION, destination);
}
</script>
</body>
</html>