2

wrong marker position on Google map

My library: com.google.maps.android:android-maps-utils:0.4.2

On initial addMarker, marker is sometimes put randomly somewhere on the map, far away from intended position.

After zoom is applied, marker finds it's correct place. I couldn't figure why, so I "solved" this with unnoticable delayed zoom:

Handler handler = new Handler();
handler.postDelayed(new Runnable() {
    @Override
    public void run() {                                    
        map.animateCamera(CameraUpdateFactory.zoomBy(0.0000001f));
    }
}, 1200);

So, my markers load, some of them are in incorrect positions for 1 second, then they jump to correct places. But there has to be another solution.

This happens to me only in case if I draw route. If there are only markers on the map, without route, I've never seen this problem. Maybe it's connected to polyline somehow. It's not connected to maker clustering though. As this happens to me both on pages where clustering is present and not.

Questions, closest to my problem that I found:

Marker changes its position while zoom in or out in google map v2 in android - no answers

Android Maps v2 custom marker has incorrect position on zoom - setting anchor doesn't help in my case.

Gmap.Net Marker at incorrect position but when the map is zoomed the marker goes to right place - I'm not using overlay

Any suggestions appreciated.

Community
  • 1
  • 1
Valeriya
  • 1,067
  • 2
  • 16
  • 31

2 Answers2

0

Please test with version 0.5 of the library.

BhalchandraSW
  • 714
  • 5
  • 13
-1
    map.animateCamera(CameraUpdateFactory.zoomBy(5f));
PRATEEK BHARDWAJ
  • 2,364
  • 2
  • 21
  • 35
  • Thank you but I'm trying to find solution WITHOUT using zoom. Need to know the reason for this behaviour, not a way to hack it. – Valeriya May 31 '17 at 13:45
  • write your code out of handler. because after 1 second interval it will zoom again and again. – PRATEEK BHARDWAJ May 31 '17 at 13:47
  • Oops, I've used Handler couple of times similar way for one time task scheduling, without problem. But will do my reading on Handlers, thank you. – Valeriya May 31 '17 at 14:47