TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
karthika pommudu
NA
321
35k
Help,to stop this back moving ‘B’ to ‘A’ marker
Feb 28 2019 11:22 PM
Here the marker moving from one position 'A' to 'B'
but the marker back to move 'B' to 'A' position ,I want to stop the backward 'B' to 'A' position...
var map, marker;
var startPos = [8.769332, 78.125176];
var speed = 5000;
// km/h
var delay = 100;
function animateMarker(marker, coords, km_h)
{
var target = 0;
var km_h = km_h || 50;
coords.push([startPos[0], startPos[1]]);
function goToPoint()
{
var lat = marker.position.lat();
var lng = marker.position.lng();
var step = (km_h * 1000 * delay) / 3600000;
// in meters
var dest =
new
google.maps.LatLng(
coords[target][0], coords[target][1]);
var distance =
google.maps.geometry.spherical.computeDistanceBetween(
dest, marker.position);
// in meters
var numStep = distance / step;
var i = 0;
var deltaLat = (coords[target][0] - lat) / numStep;
var deltaLng = (coords[target][1] - lng) / numStep;
function moveMarker()
{
lat += deltaLat;
lng += deltaLng;
i += step;
if
(i < distance)
{
marker.setPosition(
new
google.maps.LatLng(lat, lng));
setTimeout(moveMarker, delay);
}
else
{ marker.setPosition(dest);
target++;
if
(target == coords.length){ target = 0; }
setTimeout(goToPoint, delay);
}
}
moveMarker();
}
goToPoint();
}
function initialize()
{
var myOptions = {
zoom: 16,
center:
new
google.maps.LatLng(8.769332, 78.125176),
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map =
new
google.maps.Map(document.getElementById(
"map_canvas"
), myOptions);
marker =
new
google.maps.Marker({
position:
new
google.maps.LatLng(startPos[0], startPos[1]),
map: map
});
google.maps.
event
.addListenerOnce(map,
'idle'
, function()
{
animateMarker(marker, [
// The coordinates of each point you want the marker to go to.
// You don't need to specify the starting position again.
[8.772708, 78.118725],
[8.769332,78.125176],
[8.765796,78.13168]
], speed);
});
}
initialize();
Reply
Answers (
1
)
How To Host Your ASP.NET MVC Website On bigrock
How to load XML data as a content on SideBar