在谷歌地图中闪烁标记

时间:2017-12-13 07:42:39

标签: android google-maps location maps

我在"出租车应用程序"标记消失第二次并再次出现 在locationchanged功能 怎么解决这个问题?

@Subscribe(threadMode = ThreadMode.MAIN)
public void onDriversLocationResult(GetDriversLocationResultEvent event) {
    if (event.response != ServerResponse.OK)
        return;
    for (Marker marker : driverMarkers) {
        marker.remove();
        driverMarkers.remove(marker);
    }
    for (Driver driver : event.drivers)
        addDriverToMap(driver);
}

public void addDriverToMap(Driver driver) {
    driverMarkers.add(mMap.addMarker(new MarkerOptions()
            .position(new LatLng(driver.getLat(), driver.getLng()))
            .rotation(driver.getBearing())
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker_taxi))));
}

0 个答案:

没有答案