place marker on polyline with specific distance

前端 未结 2 605
情深已故
情深已故 2021-01-16 01:00

I have made a google map using google map api v3 and placed a polyline on map here is my code for my map

function initialize() {
            var myLatLng = n         


        
2条回答
  •  不要未来只要你来
    2021-01-16 01:18

    I could not deploy the logic in my case, since the creation of my markers are separated, as I define the first and útilmo, and other markings, this function is called in the end initialize():

    function calcRoute() {
    var myTrip=[];
    var bounds = new google.maps.LatLngBounds();
        
    
            var dt = '${listaCoord.dtSistema}';                 
            var cod = '${listaCoord.codDaf}';
            var lat = '${listaCoord.idLatitude}';
            var lng = '${listaCoord.idLongitude}';
            var bt = '${listaCoord.bateria}';
    
            var pt = new google.maps.LatLng(lat, lng);
    
            myTrip.push(pt);
            bounds.extend(pt);
    
            
                
                    dt = dt + ' - ATUAL';
                    atual = pt;
                    createMarkerAtual(pt,cod,dt,bt,map);
                
    
                
                    dt = dt + ' - PARTIDA';
                    inicio = pt;
                    createMarkerPartida(pt,cod,dt,bt,map);
                
    
                
                    createMarker(pt,cod,dt,bt,map);
                
            
    
        
    
        var flightPath = new google.maps.Polyline({
               path:myTrip,
               strokeColor:"#0000FF",
               strokeOpacity:0.5,
               strokeWeight:4
             });
    
        flightPath.setMap(map);
        map.fitBounds(bounds);
    }
    

    this function is create markers (no the start, no the end point):

    function createMarker(point,info,dt,bt,map) {
    var iconURL = 'img/pata.png';               
    var iconSize = new google.maps.Size(32,34);
    var iconOrigin = new google.maps.Point(0,0);    
    var iconAnchor = new google.maps.Point(15,30);
    
    var myIcon = new google.maps.MarkerImage(iconURL, iconSize, iconOrigin, iconAnchor);
    
    var marker = new google.maps.Marker({
      position : point,
      html : info,
      map : map,
      icon: myIcon
    });   
    
    google.maps.event.addListener(marker, 'click', function() {
        endereco(info,this.position,dt,bt);
        infowindow.open(map,this);
    });
    
    }
    

提交回复
热议问题