Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

232
Vistas
Uncaught TypeError: Cannot read property 'firstChild' of null (Google maps failing to load)

I was wondering if someone would be able to lend me their knowledge involving the Google Maps API. I've read similar questions and still haven't been able to come up with an answer. As the title says the error showing up in my browser console is:

Uncaught TypeError: Cannot read property 'firstChild' of null

I understand that this means there is an issue with the way values are being passed around; Following is my relevant code snippets where sources points to in Chrome:

// --- Global Variable
var map;


// --- View Model.
function AppViewModel() {

  // Initial Map
  map = new google.maps.Map(document.getElementById('map'), {
    center: {lat: 39.305, long: -76.617},
    zoom: 12
  });


// --- Initalize Application.
function initApp() {
  ko.applybindings(new AppViewModel());
}

The error appears to be thrown when Google Maps attempts to load. Does anyone have an idea as to what I'm doing wrong here? Thanks for any help offered.

Html for reference:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Bolton Hill Neighborhood Map</title>
  <link rel="stylesheet" href="static/main.css">
  <meta name="viewport" content"width=device-width, initial-scale=1">
</head>
<body>
 <div class='map'>maps error</div>

  <script src="./js/knockout.js"></script>
  <script src="./js/jquery.min.js"></script>
  <script src="./js/app.js"></script>
  <script async defer src="https://maps.googleapis.com/maps/api/js?key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX&callback=initApp" onerror="errorHandler"></script>
</body>
</html>
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I think center: {lat: 39.305, long: -76.617}, with long is not correct.
You should define latlng like this:

var latlng = new google.maps.LatLng(39.305, -76.617);
map = new google.maps.Map(document.getElementById('map'), {
  center: latlng,
  zoom: 12
});

and

Uncaught TypeError: Cannot read property 'firstChild' of null

Error message usually occurs when the maps container does not exist:

map = new google.maps.Map(document.getElementById('id_that_does_notexist'), {

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda