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

104
Visualizações
Maps is not showing in a Laravel project

I want google maps in my Laravel project where I can plot the complex polyline in the map but the map is not showing at all. It just shows a blank div.

<tr>
    <td colspan="4">
       <div id="map"></div>
    </td>
</tr>

 <!-- Map Script -->
<script
    src="https://maps.googleapis.com/maps/api/js?key=MYAPIKEY&callback=initMap&v=weekly&channel=2"
    async></script>
<script>
    // This example creates a 2-pixel-wide red polyline showing the path of
    // the first trans-Pacific flight between Oakland, CA, and Brisbane,
    // Australia which was made by Charles Kingsford Smith.
    function initMap() {
        const map = new google.maps.Map(document.getElementById("map"), {
            zoom: 3,
            center: { lat: 0, lng: -180 },
            mapTypeId: "terrain",
        });
        const flightPlanCoordinates = [
            { lat: 37.772, lng: -122.214 },
            { lat: 21.291, lng: -157.821 },
            { lat: -18.142, lng: 178.431 },
            { lat: -27.467, lng: 153.027 },
        ];
        const flightPath = new google.maps.Polyline({
            path: flightPlanCoordinates,
            geodesic: true,
            strokeColor: "#FF0000",
            strokeOpacity: 1.0,
            strokeWeight: 2,
        });

        flightPath.setMap(map);
    }
</script>

Is there any specific packages I have to install for this component to run? Or is there anything that I need to defined in any files? Please help me, whenever I see the same problem like mine, there's no answer....

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

0

Always set the map height explicitly to define the size of the div * element that contains the map:

#map { 
   height: 200px; 
   width: 100%; 
}
about 4 years ago · Juan Pablo Isaza Relatório

0

When I put the javascript function first before HTML, the map appear with functional polyline.

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