我正在研究车辆跟踪系统。 我有一个这样的lat long数组:
{"lat":"18.4560183333","lng":"73.8247583333"},
{"lat":"18.4537883333","lng":"73.8249266667"},
{"lat":"18.4547783333","lng":"73.8247633333"},
{"lat":"18.4534366667","lng":"73.8220883333"},
...
现在我想绘制多线并将车移过来。 同样如:https://jsfiddle.net/geocodezip/3b3j61pq/4/
请帮帮我。
答案 0 :(得分:0)
尝试此代码并以延迟
循环通过latlon数组LatLng currentPos = new LatLng(latitude, longitude);
carMarker.setPosition(currentPos);
double bearing = 0;
if(previousLocation!=null)
bearing = currentPos.bearingTo(previousLocation); // returns values between -180 to 180
float rotation = bearing;
if(rotation<0)
rotation= 360+rotation; //haven't checked this hope this will correct the angle
carMarker.setRotation(rotation); //to rotate the carMarker along the polyline
map.invalidate();
previousLocation = currentLocation;
如果carmarker仍然没有移动,请尝试删除并在循环中再次添加