Skip to content

Generate dynamic KML and load it with Maps API

Hi all i have task to create monitoring of 200 ip addresses and for each of this ip we have location latitude/longitude. Now for the monitoring purpose i have perl script runing which pings all 200hosts and update their status in MySql database.

Now i want to display these 200 locations on google maps and change marker color depending on status Green = online, Red = offline.

Also i have loaded kml fille with location of the connections and street cabling ( This is fixed and no changes are needed )

How can i generate markers dynamically and display them all together with already loaded kml fille?

Or if there is any other solution i am willing to consider it.

Here is a sample where i am loading my kml fille:

<!DOCTYPE html>
    <title>KML Layers</title>
    <script src=""></script>
        src=" API&callback=initMap&libraries=&v=weekly"
    <style type="text/css">
        /* Always set the map height explicitly to define the size of the div
         * element that contains the map. */
        #map {
            height: 100%;

        /* Optional: Makes the sample page fill the window. */
        body {
            height: 100%;
            margin: 0;
            padding: 0;
        "use strict";

        function initMap() {
            const map = new google.maps.Map(document.getElementById("map"), {
                zoom: 12,
                center: {
                    lat: 35.928926,
                    lng: 14.462688
            const ctaLayer = new google.maps.KmlLayer({
                url: "MY KML ADDRESS",
                map: map
<div id="map"></div>



I ended up using MySql to Maps