Android – refresh tags on cluster manager
•
Android
When the user navigates the map, the application will get a new location for him to view. However, the map does not use new tags to make it refreshing
After receiving JSON with locations, this method places them on the map
private void setMarkers(JSONObject response) {
mClusterManager.clearItems();
try {
JSONArray venues = response.getJSONArray("venues");
for (int i = 0; i < venues.length(); i++) {
Venue venue = new Gson().fromJson(venues.getJSONObject(i).toString(), Venue.class);
MarkerItem marker = new MarkerItem(venue.getLat(), venue.getLng(), venue, R.drawable.pin_quente);
mClusterManager.addItem(marker);
}
} catch (JSONException e) {
e.printStackTrace();
}
}
The first request made them well, but the second request did nothing
resolvent:
use:
mClusterManager.cluster();
After marking
private void setMarkers(JSONObject response) {
mClusterManager.clearItems();
try {
JSONArray venues = response.getJSONArray("venues");
for (int i = 0; i < venues.length(); i++) {
Venue venue = new Gson().fromJson(venues.getJSONObject(i).toString(), Venue.class);
MarkerItem marker = new MarkerItem(venue.getLat(), venue.getLng(), venue, R.drawable.pin_quente);
mClusterManager.addItem(marker);
}
mClusterManager.cluster();
} catch (JSONException e) {
e.printStackTrace();
}
}
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码