【发布时间】:2017-02-01 12:03:55
【问题描述】:
我知道以前有人问过这个问题,但是我没有得到解决方案。我的 android 应用程序开始显示我在非洲的位置,然后相机移向我当前的位置。任何人都可以帮助理解这种行为并为我提供一些解决方案来解决这个问题。
下面是我的部分代码
//ON CONNECTION SUCCESSFUL USING GOOGLECLIENTAPI
@Override
public void onConnected(Bundle bundle) {
checkPermission();
Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
if (location != null) {
pointUserCurrentLocationOnMap(location);
userLocation = location;
saveLocationIfDoesNotExistInSqliteAndBackend();
} else {
checkSettingIsProper();
}
}
public void pointUserCurrentLocationOnMap(Location lastknownLocation) {
mMap.clear();
enableUserLocationButton(true);
userLocation = lastknownLocation;
currentLocation = new LatLng(lastknownLocation.getLatitude(), lastknownLocation.getLongitude());
MarkerOptions markerOptions = new MarkerOptions().position(currentLocation).title("You");
Marker marker = mMap.addMarker(markerOptions);
marker.setIcon(BitmapDescriptorFactory.fromResource(R.drawable.ic_person_pin_circle_black_24dp));
marker.showInfoWindow();
//bounds= latlngbound which is initialize when user search some thing
if (bounds != null) {
mMap.moveCamera(CameraUpdateFactory.newLatLngBounds(bounds, (int) JobSmithApplication.convertPixelsToDp(50f, this)));
} else {
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(currentLocation, 14f));
}
mMap.setOnMarkerClickListener(this);
mMap.setOnMyLocationButtonClickListener(this);
}
我的代码有问题吗?
【问题讨论】:
标签: android geolocation google-maps-android-api-2