How to I make a marker that moves?

72 views
Skip to first unread message

Paul Bono

unread,
Nov 7, 2011, 12:30:10 AM11/7/11
to google-map...@googlegroups.com
I am trying to track a car that outputs GPS coordinates to me.  I have no issue grabbing the coordinates but I do have trouble getting the marker to move from its initial state.  I've looked online and could only find examples for marker movement in the v2 JavaScript API.  I however would like to use v3.5 or higher.  I'd also like to refrain from using any3rd party scripts.

So I need help displaying a marker and then having the marker move with the v3 Javascript API.

I currently have something like this (the variables are defined globally):

function updateMarker(){
    car = getPos(1);
    carLatlng = new google.maps.LatLng(carLatitude, carLongitude);
    carmarker = new google.maps.Marker({
        position: carLatlng,
    });
    setTimeout(updateMarker(), 3000);
}

Any help would be greatly appreciated!

Thanks in advance!!

geoco...@gmail.com

unread,
Nov 7, 2011, 1:20:59 AM11/7/11
to Google Maps JavaScript API v3
On Nov 6, 9:30 pm, Paul Bono <paul.b...@gmail.com> wrote:
> I am trying to track a car that outputs GPS coordinates to me.  I have no
> issue grabbing the coordinates but I do have trouble getting the marker to
> move from its initial state.  I've looked online and could only find
> examples for marker movement in the v2 JavaScript API.  I however would
> like to use v3.5 or higher.  I'd also like to refrain from using any3rd
> party scripts.
>
> So I need help displaying a marker and then having the marker move with the
> v3 Javascript API.

You mean something like this?
http://www.geocodezip.com/v3_animate_marker_directions.html

--Larry
Reply all
Reply to author
Forward
0 new messages