Reputation: 571
I am using SupportMapFragment
and when I use GoogleMap
with Internet it is easy to show blue point from GoogleMaps Android to show my location and zoom camera to it, but when my app is in offline mode but location is on I can easily zoom to my location but can't show that blue point.
if (mGoogleMap != null) {
List<RestaurantDTO> local = new ArrayList<>();
local.addAll(mRestData);
mGoogleMap.setInfoWindowAdapter(new RestaurantAdapter());
mGoogleMap.setMyLocationEnabled(true);
mGoogleMap.getMyLocation();
mGoogleMap.getFocusedBuilding();
So here I think main mGoogleMap.setMyLocationEnabled(true);
and mGoogleMap.getMyLocation();
methods so that when I delete then it doesn't show my blue circle pin.
Upvotes: 0
Views: 881
Reputation: 571
Map doesn't cache anything, you need to check if you have internet connection and set location source
if (!CommonUtils.isHasInternetConnection(mCtx)) { .icon(BitmapDescriptorFactory.fromResource(R.drawable.blue_google_maps_img)));
LocationSource source = new LocationSource() {
@Override
public void activate(OnLocationChangedListener onLocationChangedListener) {
Location location = new Location("myProvider");
location.setLatitude(mCurrLatLng.latitude);
location.setLongitude(mCurrLatLng.longitude);
onLocationChangedListener.onLocationChanged(location);
}
@Override
public void deactivate() {
}
};
mGoogleMap.setLocationSource(source);
}
Upvotes: 1