Reputation: 1
I am using the tutorial in google maps code found here: http://code.google.com/apis/maps/articles/phpsqlajax_v3.html
and I am loading my markers from the mysql database.
What I want is to make markers move in an way that they represent the movements of a bus.
Is it possible?
Can it be done with polyline?
Upvotes: 0
Views: 3669
Reputation: 20371
This sounds like a simple matter of using Marker#setPosition()
. As you get the new positions for buses, get a reference to the marker for each bus and update it's LatLng
value. You might maintain an array of markers that you iterate over or some sort of a mapping between bus identifier and it's marker.
And I don't understand how you would represent the movements of a bus using a polyline - that doesn't make sense. However, if you want to update a polyline, then you might do it by updating the path
MVCArray passed to create the polyline. According to the documentation:
path MVCArray.| Array.
The ordered sequence of coordinates of the Polyline. This path may be specified using either a simple array of LatLngs, or an MVCArray of LatLngs. Note that if you pass a simple array, it will be converted to an MVCArray Inserting or removing LatLngs in the MVCArray will automatically update the polyline on the map.
Upvotes: 2