• JavaScript
  • HTML

 * Adds two SVG markers over the homes of the Chicago Bears and Chicago Cubs
 * @param  {H.Map} map      A HERE Map instance within the application
function addSVGMarkers(map){
  //Create the svg mark-up
  var svgMarkup = '' +
  '' +

  // Add the first marker
  var bearsIcon = new H.map.Icon(
    svgMarkup.replace('${FILL}', 'blue').replace('${STROKE}', 'red')),
    bearsMarker = new H.map.Marker({lat: 41.8625, lng: -87.6166 },
      {icon: bearsIcon});


  // Add the second marker.
  var cubsIcon = new H.map.Icon(
    svgMarkup.replace('${FILL}', 'white').replace('${STROKE}', 'orange')),
    cubsMarker = new H.map.Marker({lat: 41.9483, lng: -87.6555 },
      {icon: cubsIcon});


 * Boilerplate map initialization code starts below:

//Step 1: 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();

//Step 2: initialize a map - this map is centered over Chicago.
var map = new H.Map(document.getElementById('map'),
  center: {lat:41.881944, lng:-87.627778},
  zoom: 11,
  pixelRatio: window.devicePixelRatio || 1
// add a resize listener to make sure that the map occupies the whole container
window.addEventListener('resize', () => map.getViewPort().resize());

//Step 3: make the map interactive
// 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));

// Create the default UI components
  var ui = H.ui.UI.createDefault(map, defaultLayers);

// 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>Display a map with custom SVG 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>SVG Graphic Markers</h1>
        <p>Display a map with custom SVG markers</p>
    <p>This example displays a movable map of <b>Chicago</b> with two individually 
      colored SVG markers highlighting the location of <b>Soldier Field</b> <i>(41.8625°N, 87.6166°W)</i>
      and <b>Wrigley Field</b> <i>(41.9483°N, 87.6555°W)</i>. These locations are the home of the 
      Chicago Bears and Chicago Cubs respectively, and each marker displays the letter <b>C</b> in the correct club colors.</p>
    <div id="map"></div>
    <script type="text/javascript" src='demo.js'></script>
    <p>SVG Graphics images are created using the <code>H.map.Icon</code> class. The icon is added as a parameter when creating an <code>H.map.Marker</code>.</p>