• JavaScript
  • HTML
                  
                  

                  
                
                  
                  
<!DOCTYPE html>
<html>
  <head>
    <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>Zooming to a Set of 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" >window.ENV_VARIABLE = 'https://developer.here.com'</script><script src='https://developer.here.com/javascript/src/iframeheight.js'></script></head>
  <body id="markers-on-the-map">
    <div class="page-header">
        <h1>Zooming to a Set of Markers</h1>
        <p>Alter the viewport to ensure a group of objects are visible</p>
    </div>
    <p>This examples adds three markers showing the locations of 
      <b>Boston</b>, <b>Washington</b> and <b>Toronto</b> to the map and alters the map display to ensure that all of the markers are visible.</p>
    <div id="map"></div>
    <h3>Code</h3>
    <p>An <code>H.map.Group</code> is used to associate the markers together and the <code>group.getBounds()</code>
      method to find the minimal bounding box holding all of the group's contents. 
      The <code>map.viewBounds()</code> can then be updated.</p>
    <script type="text/javascript" src='demo.js'></script>
  </body>
</html>