Skip to content
Branch: master
Find file Copy path
Find file Copy path
9 contributors

Users who have contributed to this file

@zbigg @musculman @chfw @dbabbs @amsXYZ @blazejkroll @zellm @gferon @ninok
235 lines (177 sloc) 7.64 KB

Getting Started Guide

To begin with, we provide a few starting points:

Import with simple bundle

Add three.js and to your html and create a canvas with an id map:

         body, html { border: 0; margin: 0; padding: 0; }
         #map { height: 100vh; width: 100vw; }
      <script src=""></script>
      <script src=""></script>
      <canvas id="map"></canvas>
      <script src="index.js"></script>

Initialize the map:

const map = new harp.MapView({
   canvas: document.getElementById("map"),
   theme: "",
const controls = new harp.MapControls(map);

window.onresize = () => map.resize(window.innerWidth, window.innerHeight);

   new harp.GeoCoordinates(37.773972, -122.431297), //San Francisco

const omvDataSource = new harp.OmvDataSource({
   baseUrl: "",
   apiFormat: harp.APIFormat.XYZOMV,
   styleSetName: "tilezen",
   authenticationCode: "YOUR-XYZ-TOKEN",

You need to obtain authentication code to replace 'YOUR-XYZ-TOKEN'.

For more information on the simple bundle, please visit the @here/ module directory.

For an in depth tutorial on getting started with, please visit the HERE Developer portal.

Create Typescript app using Yeoman

You can create simple app using Yeomans generator @here/

mkdir 3dmap-example
cd 3dmap-example
npx -p yo -p @here/ yo @here/

Integrate into your existing Webpack based project

Introduction is distributed as CommonJS modules conatined in npm packages. Modules in CommonJS format require us to use some javascript code bundler - this example will faciliate webpack.


Install them into your project:

npm install --save @here/harp-mapview @here/harp-omv-datasource @here/harp-map-theme three@0.104

You have installed 3 key components needed to render basic map:

  • @here/harp-mapview - map renderer itself
  • @here/harp-omv-datasource - tile provider based on OMV/MVT vector tile format
  • @here/harp-map-theme - default theme and font resources required to render map in OMV/tilezen scheme
  • three - Three.js - a mandatory dependency of

Decoder bundle

Our example will decode OMV/MVT tiles in Web Workers, so we can achieve high performance because creating geometry from vector tiles is CPU intensive. For this, we need to create separate bundle with code that will run in Web Workers dedicated to decoding.

You need to add this config to your Webpack config:

const appConfig = {
    // your app config
const harpGlDecodersConfig = {
    target: "webworker",
    entry: {
        decoder: "./harp-gl-decoders.js"
    output: {
        filename: "harp-gl-decoders.bundle.js"
    mode: process.env.NODE_ENV || "development"
return [appConfig, harpGlDecodersConfig];

The ./harp-gl-decoders.js needs to initialize decoding service:

import { OmvTileDecoderService } from "@here/harp-omv-datasource/index-worker";


Create DOM container renders map on HTML canvas element. Add it to your HTML document:

<!-- index.html -->
<canvas id="mapCanvas"></canvas>
    #mapCanvas {
        width: 500px;
        height: 300px;
        padding: 0;
        border: 0;


Then, you have to create MapView that is will render map on mapCanvas:

// index.js
import { MapView } from "@here/harp-mapview";

const mapCanvas = document.getElementById("mapCanvas");
const mapView = new MapView({
    canvas: mapCanvas,
    theme: "node_modules/@here/harp-map-theme/resources/berlin_tilezen_base.json",
    // note, this URL may vary depending on configuration of webpack
    // for this example, it is assumed that app is server from project root
    decoderUrl: "harp-gl-decoders.bundle.js"
    // note, this URL may vary depending on configuration of webpack
    // for this example, it is assumed that webpack emits bundles to project root

Next, you have to initialize default view settings like camera height over ground and location of map center:

// index.js
import { GeoCoordinates } from "@here/harp-geoutils";

// ..., 0, 800);
mapView.geoCenter = new GeoCoordinates(40.70398928, -74.01319808, 0);
mapView.resize(mapCanvas.clientWidth, mapCanvas.clientHeight);

Attach data source

Last step is adding some OmvDataSource to our MapView instance:

import { APIFormat, AuthenticationTypeMapboxV4, OmvDataSource } from "@here/harp-omv-datasource";

const dataSource = new OmvDataSource({
    baseUrl: "",
    apiFormat: APIFormat.XYZOMV,
    styleSetName: "tilezen",
    maxZoomLevel: 17,
    authenticationCode: "your access token for xyz service",
    authenticationMethod: AuthenticationTypeMapboxV4

Note, that this example uses vector tiles downloaded from HERE XYZ service and access to these files is protected by access token. You should replace your access token for xyz service with real one, see HERE Credentials section below.

Enable user interaction with map

What we've achieved so far is basic, static non-interactive. If you want to enable control of map like panning, rotating use MapControls

Note, this requires additional module: npm install --save @here/harp-map-controls.

import { MapControls } from "@here/harp-map-controls";

Examine examples

To begin with, we suggest taking a look at our most basic example, the equivalent of a hello_world in the examples package

HERE Credentials

In order to use some of the HERE Services, such as XYZ or Map Tile API, you would need to register and generate credentials.

First, you need to become a HERE Developer.

Afterwards, depending on which service do you want, you might need different credentials.

For Map Tile API, which is needed for the webtile examples, you need to generate a pair of app_id and app_code, that you can do directly from your Developer Dashboard, see a step-by-step guide here.

For XYZ Vector Tiles, you need an access_token that you can generate yourself from the Token Manager.

These credentials need to be passed to the Service in order to retrieve tiles, please see the examples to check how it is done.

You can’t perform that action at this time.