生成动态KML并使用Maps API加载它

问题描述

大家好,我有任务来创建200个IP地址的监视,对于每个IP地址,我们都有位置的纬度/经度。现在出于监视目的,我运行了perl脚本,可对所有200个主机执行ping操作,并更新其在MysqL数据库中的状态。

现在,我想在Google地图上显示这200个位置,并根据状态绿色=在线,红色=离线更改标记颜色。

我还向kml fille加载了连接和街道电缆的位置(这是固定的,不需要更改)

如何动态生成标记并将其与已加载的kml填充一起显示

或者如果我有其他解决方案,我愿意考虑。

这是我正在加载kml填充的示例:

<!DOCTYPE html>
<html>
<head>
    <title>KML Layers</title>
    <script src="https://polyfill.io/v3/polyfill.min.js?features=default"></script>
    <script
        src="https://maps.googleapis.com/maps/api/js?key=MY API&callback=initMap&libraries=&v=weekly"
        defer
    ></script>
    <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. */
        html,body {
            height: 100%;
            margin: 0;
            padding: 0;
        }
    </style>
    <script>
        "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
            });
        }
    </script>
</head>
<body>
<div id="map"></div>
</body>
</html>

解决方法

我最终使用 MySql to Maps

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...