Updating a map marker in android

2020-08-26 08:29发布

Using Google Maps Android API v2, I can update my marker's position by getting the Marker from a hashMap and then calling:

Marker marker = hashMap.get(someId);
marker.setTitle("Title");
marker.setSnippet("Snippet");
marker.setPosition(new LatLng(newLatitude, newLongitude));

However, if the marker is selected when this is called, the title and snippet will only update if I click off the marker and reselect it. Is there anyway to tell the map to refresh the data in the marker bubble?

1条回答
再贱就再见
2楼-- · 2020-08-26 08:48

Call hideInfoWindow() immediately followed by a call to showInfoWindow(), like this:

marker.hideInfoWindow();
marker.showInfoWindow();
查看更多
登录 后发表回答