Updating a map marker in android

女生的网名这么多〃 提交于 2019-12-22 04:17:10

问题


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:


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

marker.hideInfoWindow();
marker.showInfoWindow();


来源:https://stackoverflow.com/questions/15249720/updating-a-map-marker-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!