Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

304
Views
@here/maps-api-for-javascript not working next js

I am trying to figure out why @here/maps-api-for-javascript is not working in next js and throwing the below error:

import H from "@here/maps-api-for-javascript";

export default H;
^^^^^^

SyntaxError: Unexpected token 'export'
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

The way to resolve this issue is with a Dynamic Import with no SSR. If you follow the Using React guide provided by HERE, you will need to import the Map component as follows:

import dynamic from "next/dynamic";

function App() {
  const Map = dynamic(() => import("./Map"), {
    ssr: false
  });
  return (
    <div>
      <Map />
    </div>
  );
}

export default App;
about 4 years ago · Juan Pablo Isaza Report

0

Please try the below snippet and refer to the following guide for more details: https://developer.here.com/documentation/maps/3.1.29.0/dev_guide/topics/react-practices.html

import React from 'react'; 

import H from "@here/maps-api-for-javascript"; 

export default class Map extends React.Component { 

  constructor(props) { 

    super(props); 

    // the reference to the container 

    this.ref = React.createRef(); 

    // reference to the map 

    this.map = null; 

  } 

  
  componentDidMount() { 

    if (!this.map) { 

      // instantiate a platform, default layers and a map as usual 

      const platform = new H.service.Platform({ 

        apikey: '{YOUR_API_KEY}' 

      }); 

      const layers = platform.createDefaultLayers(); 

      const map = new H.Map( 

        this.ref.current, 

        layers.vector.normal.map, 

        { 

          pixelRatio: window.devicePixelRatio, 

          center: {lat: 0, lng: 0}, 

          zoom: 2, 

        }, 

      ); 

      this.map = map; 

    } 

  } 

  
  render() { 

    return ( 

      <div 

        style={{ width: '300px', height:'300px' }} 

        ref={this.ref} 

      /> 

    ) 

  } 

} 
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!