-1

I am working on a vehicle tracking solution. I have a polyline on which I animate a symbol(that looks like car) to make it look like car is moving on map. When my user clicks on the car, I want to open a infowindow to show driver's name and mobile number.

I can open infowindow if a marker is clicked, but I don't know how to do the same for a sybmol moving on polyline.

PCP
  • 79
  • 1
  • 5

1 Answers1

0

You can use

   marker.setPosition(latlng);

for change position

and assign to marker an icon like your symbol

 var marker = new google.maps.Marker({
        position: feature.position,
        icon: your_symbol_image.png,
        map: map
      });

simply get the postion you need and open the infowindow ..

var infowindow = new google.maps.InfoWindow({
            content: "my infowindow text content"});
   infowindow.setPosition(your_lat_lng);
   infowindow.open(map);
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
  • The icons of marker are static, but symbols can rotate on any angle. When road turns, the symbol on my polyline turns accordingly giving expression that car is turning. This can't be done if I use static icons on marker. I must use symbol moving on polyline. – PCP Mar 27 '17 at 11:38
  • or you can assign a infowindow to polyline and set the position for infowindow – ScaisEdge Mar 27 '17 at 11:43
  • mPolyline = new google.maps.Polyline({ path: path, //path on which the car needs to move strokeColor: 'black', icons: [{ icon: car, //This car is a symbol offset: '0%' }] }); the car moves on this polyline by the following code: var icons = carInstance.snappedPolyline.get('icons'); icons[0].offset = (count / 2) + '%'; carInstance.snappedPolyline.set('icons', icons); When we change the offset, the car moves from beginning of polyline till the end. – PCP Mar 27 '17 at 11:47
  • See example code by google here: https://developers.google.com/maps/documentation/javascript/examples/overlay-symbol-animate In this scenario, can you tell me how to add infowindow – PCP Mar 27 '17 at 11:52