Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps CameraUpdate moves to the wrong coordinates

I am writing an app that uses Google Maps Android API V2. The app will center on a specific latitude and longitude (this position is hard coded to 36.5323, -87.3546) when the user turns on the map and get the user's position every 15 seconds. However, when the user first turns the camera on it centers to (8.407168163601076,-87.35459994524717).

This only happens when the user first turns the map on. If the map is turned off and then turned back on, it centers on the correct coordinates. This has only happened on a Nexus 9. I have two other devices for testing where it properly centers the map on the first try.

This is the code I call to center the map:

    LatLng pos = new LatLng(36.5323, -87.3546);

    CameraUpdate center = CameraUpdateFactory.newLatLng(pos);
    CameraUpdate zoom = CameraUpdateFactory.zoomTo(14);

    map.moveCamera(center);
    map.animateCamera(zoom);

Can anyone tell me why this is happening?

like image 420
Jordan Taylor Avatar asked Apr 01 '15 20:04

Jordan Taylor


1 Answers

try this

LatLng pos= new LatLng(LATITUDE, LONGITUDE);

CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(latLng, 16);
map.animateCamera(cameraUpdate);
like image 61
Aspicas Avatar answered Oct 17 '22 15:10

Aspicas