I designed a map with routes using the DirectionsRenderer ... I need the destination marker to bounce if the source and destination are in the same place ... but when I check if the two LatLng values are the same using IF, the program does not execute IF statement ... the destination token does not receive a rebound .. my encoding
var myOptions =
{
center: new google.maps.LatLng(default_latitude,default_longitude),
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map"),myOptions);
var latlng1=new google.maps.LatLng(glat,glon);
var latlng2=new google.maps.LatLng(hlat,hlon);
var marker = new google.maps.Marker({
icon: "http://www.googlemapsmarkers.com/v1/B/67BF4B/000000/00902C/",
position: new google.maps.LatLng(glat,glon),
map: map
});
var marker1 = new google.maps.Marker({
icon: " http://www.googlemapsmarkers.com/v1/A/67BF4B/000000/00902C/",
position: new google.maps.LatLng(hlat,hlon),
map: map
});
if(latlng1==latlng2)
marker1.setAnimation(google.maps.Animation.BOUNCE);
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById("panel"));
var request = {
origin: latlng1,
destination:latlng2,
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
source
share