Docs / Setup / React / HERE

HERE setup

How to use HERE on the Web through MapConductor. The HERE Maps API for JavaScript comes from a CDN rather than npm, and you construct the H.service.Platform yourself and hand it to the view.

PACKAGE
react-for-here
API KEY
Required
CSS
From the CDN
REACT NATIVE
Available
Same provider, other platformsAndroidiOS

Before you start

Node.js 18 or newer
A HERE Platform API key
STEP 01

Install

The package does not bundle HERE's JS API — it uses the H global that your page loads.

terminalnpm
npm install @mapconductor/js-sdk-core @mapconductor/js-sdk-react \
            @mapconductor/react-for-here
STEP 02

Load HERE's JS API

Load it from the CDN with script tags, exactly as HERE's own quick-start does. @mapconductor/react-for-here expects the H global they expose.

index.htmlHTML
<script src="https://js.api.here.com/v3/3.1/mapsjs-core.js"></script>
<script src="https://js.api.here.com/v3/3.1/mapsjs-core-legacy.js"></script>
<script src="https://js.api.here.com/v3/3.1/mapsjs-service.js"></script>
<script src="https://js.api.here.com/v3/3.1/mapsjs-ui.js"></script>
<script src="https://js.api.here.com/v3/3.1/mapsjs-mapevents.js"></script>
<link rel="stylesheet" href="https://js.api.here.com/v3/3.1/mapsjs-ui.css" />
STEP 03

Build the platform and hand it to the view

For HERE the key goes into H.service.Platform, not the state hook. Construct the platform with your own credentials and pass it to the view's platform prop — wrap it in useMemo so it survives re-renders.

HereMap.tsxTypeScript · React
const platform = useMemo(
  () => new H.service.Platform({ apikey: import.meta.env.VITE_HERE_API_KEY }),
  [],
);

<HereMapView2D state={state} platform={platform}>{children}</HereMapView2D>
CAUTION
Feed the key from a build-time environment variable (import.meta.env.VITE_* under Vite) and keep it out of source control. It reaches the browser either way, so always restrict it by referrer or domain so exposure is harmless.

VERIFY

What you should see

The HERE map rendering means you are done. The Web HERE provider is 2D only.

HereMap.tsxTypeScript · React
import { useMemo, useState } from 'react';
import { createGeoPoint, createMapCameraPosition, createMarkerState } from '@mapconductor/js-sdk-core';
import { Marker } from '@mapconductor/js-sdk-react';
import { HereMapDesign, HereMapView2D, useHereViewState } from '@mapconductor/react-for-here';

const TOKYO = createGeoPoint({ latitude: 35.6812, longitude: 139.7671 });

export function HereMap() {
  const state = useHereViewState({
    mapDesignType: HereMapDesign.NormalDay,
    cameraPosition: createMapCameraPosition({ position: TOKYO, zoom: 12 }),
  });
  // HERE Maps API for JavaScript is loaded from the CDN (see index.html);
  // the platform must be created with the host page's own credentials.
  const platform = useMemo(
    () => new H.service.Platform({ apikey: import.meta.env.VITE_HERE_API_KEY }),
    [],
  );
  const [markerState] = useState(() => createMarkerState({ id: 'tokyo', position: TOKYO }));

  return (
    <HereMapView2D state={state} platform={platform}>
      <Marker state={markerState} />
    </HereMapView2D>
  );
}

Map designs

HereMapDesign maps onto HERE's map schemes.

HereMapDesign
Notes
NormalDay / NormalNight
The standard style, day and night
Satellite
Satellite imagery
HybridDay / HybridNight
Satellite imagery with roads and labels
LiteDay / LiteNight
Lightweight styles
LogisticsDay
Tuned for logistics

Troubleshooting

H is undefined

  • Check the script tags in index.html load, and in the right order: core → core-legacy → service → ui → mapevents.
  • If you server-render, make sure the platform is only constructed on the client.

The map does not appear

  • Check the apikey you passed to H.service.Platform.

Switching providers throws a hook-order error

  • React will not let the hook call order change. Make one small component per provider that calls its own hook — that is exactly how the sample app's providers/ directory is laid out.

Next

For large marker sets, pass markerTilingOptions — static markers are then drawn together as a raster overlay.