Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android maps markers show on map only after zooming change

I made simple application where I get markers based on screen coordinates from the server. Problem is that markers doesn't appear on map immediately. User user must zoom in or zoom out only then marker is visible. Why is that? Is it possible to show marker as soon when marker data is downloaded from server? Or is it possible to somehow refresh map? I know that in previous version there was method map.invalidate() that is basically what I need to have now. Unfortunately this method is not available now.

I will add code snippet how my markers is added

@Override
        protected void onPostExecute(ArrayList<MarkerItemData> markerItemData) {
            super.onPostExecute(markerItemData);
            if(markerItemData != null) {
                mClusterManager.addItems(markerItemData);
            }
        }
like image 313
David Avatar asked Jan 17 '17 19:01

David


People also ask

How do I fix zoom on Google Maps?

You can change the zoom level of the map using simple steps. Step 1 Go to Add or Edit Map page . Step 2 Select 'Default zoom level' in the 'Map Information section'. Step 3 click save map and see the changes.

How do you change the zoom level on a map?

Users can zoom the map by clicking the zoom controls. They can also zoom and pan by using two-finger movements on the map for touchscreen devices.

How do I hide markers on Google Maps?

Step 1 Go to Add or Edit Map and Scroll down to the 'Infowindow Settings' section. Step 2 Enable the box of 'Hide Markers on Page Load' option. Step 3 Click on Save Map and open it in browser.


1 Answers

It needs re-clustering again.

mClusterManager.addItems(markerItemData);
mClusterManager.cluster();

Because, when you add or remove an ClusterItem (MarkerItemData), it just performs the algorithm and calculates clusters. But does not render on map

Finally, ClusterManager listens onCameraIdle event(includes zoom events) and invokes cluster() method internally. This is the answer of user must zoom in or zoom out only then marker is visible.

like image 179
blackkara Avatar answered Sep 28 '22 19:09

blackkara