2

我正在使用Google Earth 插件来同时显示多个多边形(圆圈),我该怎么做?,我有一个带有 lat orgeoDataSplit[0]和 lng or的列表框geoDataSplit[1],想要通过这个列表框 latlngs,将它们传递给polyplacemark,存储所有圆圈可能在一个数组中,或者你会建议什么并显示所有圆圈,下面的代码打印所有圆圈,但一个一个而不是同时打印所有圆圈:

var setOfPlacemarks = [];
function createCircle(centerLat, centerLng, radius) {

    function make2Circle(centerLat, centerLng, radius) {

        var ring = ge.createLinearRing('');
        var steps = 25;
        var pi2 = Math.PI * 2;
        for (var i = 0; i < steps; i++) {
            var lat = parseFloat(centerLat) + radius * Math.cos(i / steps * pi2);
            var lng = centerLng + radius * Math.sin(i / steps * pi2);
            ring.getCoordinates().pushLatLngAlt(lat, lng, 0);

        }
        return ring;
    }

    var polygonPlacemark = ge.createPlacemark('');
    polygonPlacemark.setGeometry(ge.createPolygon(''));
    var outer = ge.createLinearRing('');

    var dlist = document.getElementById('salesList');
        for (var i = 0; i < dlist.options.length; i++) {

            var geoData = dlist.options[i].text;
            geoDataSplit = geoData.split(",");
            polygonPlacemark.getGeometry().setOuterBoundary(make2Circle(parseFloat(geoDataSplit[0]), parseFloat(geoDataSplit[1]), .00001*parseInt(geoDataSplit[2])/5));
            polygonPlacemark.setName(geoDataSplit[2]);

            ge.getFeatures().appendChild(polygonPlacemark);
            setOfPlacemarks.push(polygonPlacemark);
        }
        printAllPlacemarks();
}

function printAllPlacemarks() {

    var kmlObjectList = ge.getFeatures().getChildNodes();
    alert(kmlObjectList);
    for (var i = 0; i < setOfPlacemarks.length; i++) {
        alert(setOfPlacemarks[i]);
        ge.getFeatures().appendChild(setOfPlacemarks[i]);
    }
}
4

0 回答 0