Question

can anyone please tell me how to make the polyline to continuously blink that uses no co-orindates . I've drawn a polyline in google-map without co-ordinates , but i could'nt make then blink like the one that blink which uses co-ordinates.

blinking polyline with co-ordinates

FIDDLE

polyline without co-ordinates (how to blink this one like the above)

FIDDLE

My code is as given below

$(function(){
 var map    = new google.maps.Map(document.getElementById("map"), {
                  center: new google.maps.LatLng(11.275387916698238, 75.8015380957031),
                  zoom: 12
               }),
     routes = [{origin:'p t usha road, kozhikode', 
               destination:'cooperative hospital, eranjipalam, kozhikode'
               }, 
               {origin:'IIM, Kozhikode',
               destination:'VELLIMADUKUNNU, KOZHIKODE'
               }
              ],
     rendererOptions = {
                preserveViewport: true,
                map:map,
                polylineOptions:{strokeColor:'#FF3300',
                                 strokeWeight: 10},        
                suppressMarkers:true,
                routeIndex:0
              },
     directionsService = new google.maps.DirectionsService();
    var i=0;
var infowindow = new google.maps.InfoWindow();
      $.each(routes,
        function(i,obj){//<--anonymous function

        var request = {
                origin: obj.origin,
                destination: obj.destination,
                travelMode: google.maps.TravelMode.DRIVING
              },

            directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
            directionsService.route(request, function(result, status) {

              if (status == google.maps.DirectionsStatus.OK) {

var lat = result.routes[0].legs[0].start_location.lat();
var lon = result.routes[0].legs[0].start_location.lng();

    var lat1 = result.routes[0].legs[0].end_location.lat();
var lon1 = result.routes[0].legs[0].end_location.lng();             



                  try{  

                  var marker1 = new google.maps.Marker({
    position: new google.maps.LatLng(lat, lon),
                      icon:'https://mts.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-b.png&text=B&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48&scale=1',
        map: map
      });

                            google.maps.event.addListener(marker1, 'click', (function(marker1, i) {
        return function() {
          infowindow.setContent('hh');
          infowindow.open(map, marker1);
        }
      })(marker1, i));                      

                  }catch(e){alert(e)}






                       try{  

                  var marker2 = new google.maps.Marker({
    position: new google.maps.LatLng(lat1, lon1),
                      icon:'https://mts.googleapis.com/vt/icon/name=icons/spotlight/spotlight-waypoint-a.png&text=A&psize=16&font=fonts/Roboto-Regular.ttf&color=ff333333&ax=44&ay=48&scale=1',
        map: map
      });



                            google.maps.event.addListener(marker2, 'click', (function(marker2, i) {
        return function() {
          infowindow.setContent('hdddh');
          infowindow.open(map, marker2);
        }
      })(marker2, i));                                     

                  }catch(e){alert(e)}




                  directionsDisplay.setDirections(result);
              }
            });  
      i++;
        });});
Was it helpful?

Solution

The polylines created by the DirectionsRenderer are not accessible via the API.

What you can do: toggle the settings of the Renderer (e.g. supressPolylines) and redraw the results:

setInterval(function () {

    directionsDisplay.set('suppressPolylines', 
                          !directionsDisplay.get('suppressPolylines'));
    directionsDisplay.setDirections(result);

}, 2000);

Demo: http://jsfiddle.net/doktormolle/927DS/

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top