Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

310
Visualizações
@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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda