Search code examples
javascriptangularhere-api

Here map Custom Style


How can i Style HERE MAP's i.e

  1. Hide Labels
  2. Change color of Water e.g. oceans, rivers
  3. Change color of Freeways and highways
  4. Change color of Arterial s e.g. avenues, boulevards
  5. Change Color of Parks, shopping centers, and airports
  6. Change color of Other land then above mentioned points (2-5)

    
/**
 * @param  {H.Map} map      A HERE Map instance within the application
 */
function moveMapToLocation(map){
  map.setCenter({lat:33.715617, lng:-117.794412});
  map.setZoom(10);
}

/**
 * Boilerplate map initialization code starts below:
 */

//Step 1: initialize communication with the platform
var platform = new H.service.Platform({
  app_id: 'DemoAppId01082013GAL',
  app_code: 'AJKnXv84fjrb0KIHawS0Tg',
  useCIT: true,
  useHTTPS: true
});
var defaultLayers = platform.createDefaultLayers();

//Step 2: initialize a map  - not specificing a location will give a whole world view.

var map = new H.Map(document.getElementById('map'),
  defaultLayers.normal.map);

//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...
moveMapToLocation(map);
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, width=device-width" />
<link rel="stylesheet" type="text/css" href="https://js.cit.api.here.com/v3/3.0/mapsjs-ui.css" />
<script type="text/javascript" src="https://js.cit.api.here.com/v3/3.0/mapsjs-core.js"></script>
<script type="text/javascript" src="https://js.cit.api.here.com/v3/3.0/mapsjs-service.js"></script>
<script type="text/javascript" src="https://js.cit.api.here.com/v3/3.0/mapsjs-ui.js"></script>
<script type="text/javascript" src="https://js.cit.api.here.com/v3/3.0/mapsjs-mapevents.js"></script>

</head>
<body>
  <div id="map" style="width: 100%; height: 400px; background: grey" />

</body>
</html>


Solution

  •    
    function moveMapToLocation(map){
     // map.setCenter({lat:33.715617, lng:-117.794412});
      //map.setZoom(10);
    var mapTileService = platform.getMapTileService({
          type: 'base'
        });
      var parameters = {};
      var tileLayer = mapTileService.createTileLayer(
          'basetile',
          'normal.night',
          512,
          'png8',
          parameters
        );
      map.setBaseLayer(tileLayer)
    }
    
    //Step 1: initialize communication with the platform
    var platform = new H.service.Platform({
      app_id: 'DemoAppId01082013GAL',
      app_code: 'AJKnXv84fjrb0KIHawS0Tg',
      useCIT: true,
      useHTTPS: true
    });
    var defaultLayers = platform.createDefaultLayers();
    var map = new H.Map(document.getElementById('map'),
    defaultLayers.normal.map,{
     center: {lat:33.716514, lng:-117.794165},     
     zoom: 11
    });
    moveMapToLocation(map,platform);
    <html>
    <head>
    <meta name="viewport" content="initial-scale=1.0, width=device-width" />
    <link rel="stylesheet" type="text/css" href="https://js.cit.api.here.com/v3/3.0/mapsjs-ui.css" />
    <script type="text/javascript" src="https://js.cit.api.here.com/v3/3.0/mapsjs-core.js"></script>
    <script type="text/javascript" src="https://js.cit.api.here.com/v3/3.0/mapsjs-service.js"></script>
    <script type="text/javascript" src="https://js.cit.api.here.com/v3/3.0/mapsjs-ui.js"></script>
    <script type="text/javascript" src="https://js.cit.api.here.com/v3/3.0/mapsjs-mapevents.js"></script>
    
    </head>
    <body>
      <div id="map" style="width: 100%; height: 400px; background: grey" />
    
    </body>
    </html>

        
    /**
     * @param  {H.Map} map      A HERE Map instance within the application
     */
    function moveMapToLocation(map){
      map.setCenter({lat:33.715617, lng:-117.794412});
      map.setZoom(10);
    }
    
    /**
     * Boilerplate map initialization code starts below:
     */
    
    //Step 1: initialize communication with the platform
    var platform = new H.service.Platform({
      app_id: 'DemoAppId01082013GAL',
      app_code: 'AJKnXv84fjrb0KIHawS0Tg',
      useCIT: true,
      useHTTPS: true
    });
    var defaultLayers = platform.createDefaultLayers();
    
    //Step 2: initialize a map  - not specificing a location will give a whole world view.
    
    var map = new H.Map(document.getElementById('map'),
      defaultLayers.normal.map);
    
    //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...
    moveMapToLocation(map);
    <html>
    <head>
    <meta name="viewport" content="initial-scale=1.0, width=device-width" />
    <link rel="stylesheet" type="text/css" href="https://js.cit.api.here.com/v3/3.0/mapsjs-ui.css" />
    <script type="text/javascript" src="https://js.cit.api.here.com/v3/3.0/mapsjs-core.js"></script>
    <script type="text/javascript" src="https://js.cit.api.here.com/v3/3.0/mapsjs-service.js"></script>
    <script type="text/javascript" src="https://js.cit.api.here.com/v3/3.0/mapsjs-ui.js"></script>
    <script type="text/javascript" src="https://js.cit.api.here.com/v3/3.0/mapsjs-mapevents.js"></script>
    
    </head>
    <body>
      <div id="map" style="width: 100%; height: 400px; background: grey" />
    
    </body>
    </html>