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

90
Vistas
Geojson File not aligning with map correctly

I have a geojson file that I'm trying to add to a map but for some reason, they are misaligned.

I have made this simplified version of the page, removing all my markers and all other HTML to try to isolate the problem but with no joy.

I've tried

  • Loading the Geojson on the page in <script> tags like the leaflet JS tutorial shows
  • Saving the Geojson in a folder on my site and calling it to load with JavaScript
  • And with the link, you see below I've used fetch to get the API

http://codeyeti.co.uk/ActiveCommuters/map_dev.php

They all return this same misaligned result.

the Geojson file can be viewed on Maptiler where it displays perfectly

https://cloud.maptiler.com/data/b92719af-8d5b-4006-9631-3d8b13eaa1c6/#9.19/53.2826/-4.3682

here is my code

<html>
<head>
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.7.1/dist/leaflet.css" crossorigin="" />
    <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js" crossorigin=""></script>
    <link rel="stylesheet" href="./css/style.css">
</head>
<body>

<div id="map"></div>
      <script>
  var map = L.map('map').setView([53.309242,-4.626208], 10);

L.tileLayer('https://api.maptiler.com/maps/openstreetmap/{z}/{x}/{y}.jpg?key=g9ErshPDnj0LYYtEd10o', {
attribution: '<a href="https://www.maptiler.com/copyright/" target="_blank">&copy; MapTiler</a> <a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap contributors</a>',
}).addTo(map);

fetch('https://api.maptiler.com/data/b92719af-8d5b-4006-9631-3d8b13eaa1c6/features.json?key=g9ErshPDnj0LYYtEd10o')
    .then(function (responce) {
    return responce.json();
    })
    .then(function (data) {
      L.geoJSON(data).addTo(map);
    });
  </script>
  
</body>

</html>

Has anyone had trouble like this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

misaligned result by style.css line 271 :

img {
   margin: 10px 0px;
}

you can check it

Map of leaflet is a group images

about 4 years ago · Juan Pablo Isaza 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