bradcornford / Googlmapper

An easy way to integrate Google Maps with Laravel
MIT License
464 stars 143 forks source link

Display KML/KMZ #375

Open poxin13 opened 3 years ago

poxin13 commented 3 years ago

Hello, is there a way to display KML/KMZ? https://developers.google.com/maps/documentation/javascript/kml

poxin13 commented 3 years ago
Mapper::map(0, -0, ['zoom' => 7, 'center' => true, 'marker' => false, 'eventBeforeLoad' => 'kmlLayers(map_0);']);

    <script type="text/javascript">
        function kmlLayers(map)
        {
            const kmlLayer = new google.maps.KmlLayer({
                url: "https://example.com/layer.kmz",
                map: map,
            });
        }
    </script>

Looks like something along these lines works.

poxin13 commented 3 years ago

Unfortunately cluster doesn't seem to work using this.

bradcornford commented 3 years ago

Hi,

This package doesn't natively support KML layers, however your event based callback would be what i suggest you do to achieve it. You may want to move it to the eventAfterLoad instead, to allow the cluster option to initialise before overwriting the KML layer.