Android多段线-逐点添加
我现在有一张地图,每10米我就使用LocationListener刷新我的位置并获得新的纬度和经度。现在,我希望用户正在使用的路线将显示为红线。因此,每次调用LocationListener类中的OnLocationChange()时,我都想用最后一个位置和新位置之间的一条线来更新映射 到目前为止,我添加了以下内容:Android多段线-逐点添加,android,google-maps,maps,google-maps-android-api-2,polyline,Android,Google Maps,Maps,Google Maps Android Api 2,Polyline,我现在有一张地图,每10米我就使用LocationListener刷新我的位置并获得新的纬度和经度。现在,我希望用户正在使用的路线将显示为红线。因此,每次调用LocationListener类中的OnLocationChange()时,我都想用最后一个位置和新位置之间的一条线来更新映射 到目前为止,我添加了以下内容: private void initializeDraw() { lineOptions = new PolylineOptions().width(5).color(Col
private void initializeDraw() {
lineOptions = new PolylineOptions().width(5).color(Color.RED);
lineRoute = workoutMap.addPolyline(lineOptions);
}
在OnLocationChanged期间,我称之为:
drawTrail();
现在,我应该在这个函数中插入什么,以便每次它都将新获得的位置添加为一个点,并从最后一个点到新点绘制一条线
谢谢首先将
位置
翻译成拉丁语
:
LatLng newPoint = new LatLng(location.getLatitude(), location.getLongitude());
然后将点添加到现有点列表中:
List<LatLng> points = lineRoute.getPoints();
points.add(newPoint);
lineRoute.setPoints(points);
List points=lineRoute.getPoints();
添加(newPoint);
线路路线。设定点(点);