【发布时间】:2017-09-18 21:16:53
【问题描述】:
情况1: 假设我用蓝色标记填充地图:
for (LatLng latLng : latLngList) {
mMap.addMarker(new MarkerOptions()
.position(latLng)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
}
单击标记时,我希望将地图上每个标记的颜色更改为黄色。我该怎么做?
目前,我只能设法更改使用此方法单击的特定标记的颜色:
@Override
public boolean onMarkerClick(Marker marker) {
//change marker colour to yellow
marker.setIcon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_YELLOW));
return false;
}
情况2: 假设我有 2 种标记,蓝色和红色,它们是从两个不同的 latLng 列表创建的。
//create blue markers
for (LatLng latLng : latLngListBlue) {
mMap.addMarker(new MarkerOptions()
.position(latLng)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
}
//create red markers
for (LatLng latLng : latLngListRed) {
mMap.addMarker(new MarkerOptions()
.position(latLng)
.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)));
}
单击 red 标记时,我希望所有 blue 标记变为黄色。我该怎么做?
【问题讨论】:
标签: java android google-maps-markers marker