如何用折线连接标记?

如何将标记与一条线连接?标记是由XML文件生成的。

我需要不断更新和下载XML文件的位置,并且它将标记与一行绑定在一起。 数据是实时输出的,因此我需要在标记通过的地方标记行。

我正在使用Google默认代码从XML文件添加书签

var histMapLink = "<?php echo "$history_map$placa" ?>";       
var map;
var infoWindow;

function initMap() {
  var map = new google.maps.Map(document.getElementById('map'),{
    center: new google.maps.LatLng(-22.894294,-43.218077),zoom: 11,//mapTypeId: 'hybrid',});

    var infoWindow = new google.maps.InfoWindow;
    // Change this depending on the name of your PHP or XML file

    function refresh() {

        setInterval(function () {

            downloadUrl(histMapLink,function (data) {

                    var xml = data.responseXML;
                    var markers = xml.documentElement.getElementsByTagName('marker');

                    Array.prototype.forEach.call(markers,function (markerElem) {
                        var id = markerElem.getattribute('id');
                        var name = markerElem.getattribute('name');
                        var speed = markerElem.getattribute('speed');
                        var placa = markerElem.getattribute('placa');
                        var address = markerElem.getattribute('address');
                        var type = markerElem.getattribute('type');
                        var uptime = markerElem.getattribute('uptime');
                        var status = markerElem.getattribute('status');
                        var destino = markerElem.getattribute('destino');
                        var point = new google.maps.LatLng(
                            parseFloat(markerElem.getattribute('lat')),parseFloat(markerElem.getattribute('lng')));


                        var infowincontent = document.createElement('div');
                        var strong = document.createElement('strong');
                        strong.textContent = "Motorista: " + name
                        infowincontent.appendChild(strong);

                        infowincontent.appendChild(document.createElement('br'));
                        var text = document.createElement('text');
                        text.textContent = "Local atual: " + address
                        infowincontent.appendChild(text);


                        var icon = customLabel[type] || {};


                        var marker = new google.maps.Marker({
                          map: map,position: point,//label: icon.label,title: name + " - " + type,//icon: iconBase + 'marker.png'
                          icon: icon.icon
                          });


                        marker.addListener('click',function () {
                            infoWindow.setContent(infowincontent);
                            infoWindow.open(map,marker);
                            //map.setzoom(map.zoom + 2);
                            map.setCenter(marker.getPosition());
                        });




                        //----------------start reload markers;

                        var call = setInterval(function(){
                          marker.setMap(null);
                          marker.setMap(initMap);
                        },5800);

                        //----------------end reload markers;


                    });
                });

        },3000);
    }

    refresh();

}



function downloadUrl(url,callback) {
    var request = window.activeXObject ?
        new activeXObject('microsoft.XMLHTTP') :
        new XMLHttpRequest;


    request.onreadystatechange = function () {
        if (request.readyState == 4) {
            request.onreadystatechange = doNothing;
            callback(request,request.status);
        }
    };

    request.open('GET',url,true);
    request.send(null);
};

function doNothing() {}
a44443 回答:如何用折线连接标记?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3113447.html

大家都在问