• JavaScript
  • HTML

function orderMarkers() {
  var zIndex = 1,
      // create a set of markers
      marker = new H.map.Marker(
        {lat: 52.508249, lng: 13.338931}
      marker2 = new H.map.Marker(
        {lat: 52.506682, lng: 13.332107}
      marker3 = new H.map.Marker(
        {lat: 52.503730, lng: 13.331678}
      marker4 = new H.map.Marker(
        {lat: 52.531, lng: 13.380}

  // add markers to the map
  map.addObjects([marker, marker2, marker3, marker4]);

  map.addEventListener('tap', function (evt) {
    if (evt.target instanceof H.map.Marker) {
      // increase z-index of the marker that was tapped

 * Boilerplate map initialization code starts below:

// initialize communication with the platform
// In your own code, replace variable window.apikey with your own apikey
var platform = new H.service.Platform({
  apikey: window.apikey
var defaultLayers = platform.createDefaultLayers();

var map = new H.Map(document.getElementById('map'),
  center: {lat: 52.5, lng: 13.4},
  zoom: 10,
  pixelRatio: window.devicePixelRatio || 1
// add a resize listener to make sure that the map occupies the whole container
window.addEventListener('resize', () => map.getViewPort().resize());

// MapEvents enables the event system
// Behavior implements default interactions for pan/zoom (also on mobile touch environments)
var behavior = new H.mapevents.Behavior(new H.mapevents.MapEvents(map));

// Now use the map as required...
<!DOCTYPE html>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=yes">
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
    <title>Ordering Overlapping Markers</title>
    <link rel="stylesheet" type="text/css" href="https://js.api.here.com/v3/3.1/mapsjs-ui.css" />
    <link rel="stylesheet" type="text/css" href="demo.css" />
    <link rel="stylesheet" type="text/css" href="styles.css" />
    <link rel="stylesheet" type="text/css" href="../template.css" />
    <script type="text/javascript" src='../test-credentials.js'></script>    
    <script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-core.js"></script>
    <script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-service.js"></script>
    <script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-ui.js"></script>
    <script type="text/javascript" src="https://js.api.here.com/v3/3.1/mapsjs-mapevents.js"></script>
  <script type="text/javascript" src='../js-examples-rendering-helpers/iframe-height.js'></script></head>
  <body id="markers-on-the-map">
    <div class="page-header">
        <h1>Ordering Overlapping Markers</h1>
        <p>Arrange the order in which a series of map objects are displayed</p>
    <p>This example shows how to arrange the visibility order of markers by clicking them. Zoom in and out to overlap markers and try re-arranging them.</p>
    <div id="map"></div>
    <p>This example uses marker's z-index value to set its rendering order.</p>
    <script type="text/javascript" src='demo.js'></script>