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

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

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 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