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

307
Visualizações
Add image overlay to Google Maps with rotate and tilt

I am trying to overlay an image onto a Google Map and I am using the instructions found here:

https://developers.google.com/maps/documentation/javascript/examples/groundoverlay-simple

When I try using the 'heading' attribute, the map correctly rotates, however, so does the image. I have tried using an image transform to rotate the picture, but I end up with a white box on the map.

Below is my javascript

let historicalOverlay;
function initMap() {
  const map = new google.maps.Map(document.getElementById("map"), {
    center: { lat: 24.960864, lng: 55.150841 },
    zoom: 16,
    tilt: 47.5,
    heading: 120,
    mapId: "90f87356969d889c",
  });
    const imageBounds = {
    north: 24.9717265,
    south: 24.9500015,
    east: 55.161841,
    west: 55.139841,
  };

  historicalOverlay = new google.maps.GroundOverlay("https://res.cloudinary.com/defmmlrqg/image/upload/a_120/v1646695548/test/img32_iidhie.jpg", imageBounds);
  historicalOverlay.setMap(map);
}

And this is my HTML

<!DOCTYPE html>
<html>
  <head>
    <title>Tilt and Rotation</title>
    <script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
    <!-- jsFiddle will insert css and js -->
  </head>
  <body>
    <div id="map"></div>
    <!-- Async script executes immediately and must be after any DOM elements used in callback. -->
    <script
      src="https://maps.googleapis.com/maps/api/js?key=AIzaSyB41DRUbKWJHPxaFjMAwdrzWzbVKartNGg&callback=initMap&v=beta&channel=2" async></script>
  </body>
</html>

https://jsfiddle.net/ef79tL45/21/

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Don't use the rotation by url with the "a_120" part on the URL. You're image don't really rotate with this method. You need to use custom overlay. In the exemple in the previous link, to rotate you're image, modify the draw method of the custom overlay class by adding something like

this.div_.style.transform = 'rotate(120deg)';

Take a look at this post for more infos.

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