【发布时间】:2020-10-24 10:31:25
【问题描述】:
我正在尝试从 Firebase 获取坐标,以便在 Google 地图上为每个用户创建不同颜色的折线。问题是当我获取这些数据并将其插入谷歌地图时,它以相同的颜色显示。
List<Integer> colors = new ArrayList<>();
colors.add(-9784993);
colors.add(-6501807);
for (int a = 0; a <= userList.size()-1; i++) {
for (DataSnapshot objSnapshot : dataSnapshot.getChildren()) {
dataClass d = objSnapshot.getValue(dataClass.class);
LatLng start = new LatLng(d.getLat(), d.getLongi());
elasticList.add(start);
polylineOptionsTest[a] = new PolylineOptions()
.addAll(elasticList)
.color(colors.get(a)) //Get color from list called "colors"
.clickable(true);
polyline2 = mMap.addPolyline(polylineOptionsTest[a]);
}
}
【问题讨论】:
标签: android google-maps polyline