如何在 Google Maps for OFBiz 中使用 KML 文件?

How to use KML file in Google Maps for OFBiz?

我正在尝试在 Google 网络 OFBiz 框架中的地图中使用 KML 文件 application.I 在数组(列表)中输入坐标值。那么,我如何开始在 Google 地图中使用 Kml 文件?

我在 .ftl 文件中插入了 google 地图的代码

function initialize() {
        var map;
        var bounds = new google.maps.LatLngBounds();
        var mapOptions = {
            mapTypeId: 'satellite'
        };

        // Display a map on the page
        map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
        map.setTilt(45);

        // Multiple Markers
        var markers = [
            ['London Eye, London', 51.503454,-0.119562],
            ['Palace of Westminster, London', 51.499633,-0.124755]
        ];

        // Info Window Content
        var infoWindowContent = [
            ['<div class="info_content">' +
            '<h3>London Eye</h3>' +
            '<p>The London Eye is a giant Ferris wheel situated on the banks of the River Thames. The entire structure is 135 metres (443 ft) tall and the wheel has a diameter of 120 metres (394 ft).</p>' +        '</div>'],
            ['<div class="info_content">' +
            '<h3>Palace of Westminster</h3>' +
            '<p>The Palace of Westminster is the meeting place of the House of Commons and the House of Lords, the two houses of the Parliament of the United Kingdom. Commonly known as the Houses of Parliament after its tenants.</p>' +
            '</div>']
        ];

        // Display multiple markers on a map
        var infoWindow = new google.maps.InfoWindow(), marker, i;
        var infoWindow1 = [];

        for( i = 0; i < farmerCropList.length; i++ ) {
            var position = new google.maps.LatLng(farmerCropList[i].latitude, farmerCropList[i].longitude);
            bounds.extend(position);
            marker = new google.maps.Marker({
                position: position,
                map: map,
                title: farmerCropList[i].farmerCropId
            });

            infoWindow1[i] = new google.maps.InfoWindow({
                  content: '<div style="padding:5px;width:100%;height:auto;">' +
                                        '<div style="padding:5px;width:400px;font-size:16px;text-align:left">Farmer Name : '+(farmerCropList[i].firstName + farmerCropList[i].lastName)+'</div>'+
                                        '</div>'
              });



            var lastOpen = -1;
             google.maps.event.addListener(marker, 'click', (function(marker, i) {
                    if (lastOpen > -1) {
                        infoWindow1[lastOpen].close();
                    }
                    return function(){
                    infoWindow1[i].open(map, marker);
                    }
                    lastOpen = i;
            })(marker, i));


            map.fitBounds(bounds);
        }

        var boundsListener = google.maps.event.addListener((map), 'bounds_changed', function(event) {
            this.setZoom(15);
            google.maps.event.removeListener(boundsListener);
        });

        google.maps.event.addDomListener(window, 'load', initialize);

    }

您可以使用 KmlLayer

查看此 google 开发人员示例

https://developers.google.com/maps/documentation/javascript/examples/layer-kml