I need to determine whether a google map is being dragged from East-to-West or West-to-East. Google search throws up loads of driving directions search results as soon as I enter a combination of map and direction but nothing relevant to the drag keyword. Though there might be some relevant results out there which haven't met my eye.
Currently I do it by comparing longitude of current center and the new center in center_changed
event -
google.maps.event.addListener(map, 'center_changed', function() {
var newCenter = map.getCenter();
var markerIcon;
if (newCenter.lng() > currentLongitude) {
markerIcon = goingEast;
} else {
markerIcon = goingWest;
}
var marker = new google.maps.Marker({
position: map.getCenter(),
map: map,
icon: markerIcon
});
});
I wonder if that's the correct way to do it or perhaps there is a property/method etc. that tells me directly what I need to know.