Java Code Examples for org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider#setLocationUpdateMinTime()

The following examples show how to use org.osmdroid.views.overlay.mylocation.GpsMyLocationProvider#setLocationUpdateMinTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MapFragment.java    From AIMSICDL with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Description:     Initialises the Map and sets initial options such as:
 *                      Zoom levels and controls
 *                      Compass
 *                      ScaleBar
 *                      Cluster Pin colors
 *                      Location update settings
 */
private void setUpMapIfNeeded() {

    // Check if we were successful in obtaining the map.
    mMap.setBuiltInZoomControls(true);
    mMap.setMultiTouchControls(true);
    mMap.setMinZoomLevel(3);
    mMap.setMaxZoomLevel(19); // Latest OSM can go to 21!
    mMap.getTileProvider().createTileCache();
    mCompassOverlay = new CompassOverlay(getActivity(), new InternalCompassOrientationProvider(getActivity()), mMap);

    ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(getActivity());
    mScaleBarOverlay.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels / 2, 10);
    mScaleBarOverlay.setCentred(true);

    // Sets cluster pin color
    mCellTowerGridMarkerClusterer = new CellTowerGridMarkerClusterer(getActivity());
    //BitmapDrawable mapPinDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_map_pin_orange);
    BitmapDrawable mapPinDrawable = (BitmapDrawable) ResourcesCompat.getDrawable(getResources(), R.drawable.ic_map_pin_orange, null);
    mCellTowerGridMarkerClusterer.setIcon(mapPinDrawable == null ? null : mapPinDrawable.getBitmap());

    GpsMyLocationProvider gpsMyLocationProvider = new GpsMyLocationProvider(getActivity().getBaseContext());
    gpsMyLocationProvider.setLocationUpdateMinDistance(100); // [m]  // Set the minimum distance for location updates
    gpsMyLocationProvider.setLocationUpdateMinTime(10000);   // [ms] // Set the minimum time interval for location updates
    mMyLocationOverlay = new MyLocationNewOverlay(getActivity().getBaseContext(), gpsMyLocationProvider, mMap);
    mMyLocationOverlay.setDrawAccuracyEnabled(true);

    mMap.getOverlays().add(mCellTowerGridMarkerClusterer);
    mMap.getOverlays().add(mMyLocationOverlay);
    mMap.getOverlays().add(mCompassOverlay);
    mMap.getOverlays().add(mScaleBarOverlay);
}
 
Example 2
Source File: MapViewerOsmDroid.java    From AIMSICDL with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Description:     Initialises the Map and sets initial options such as:
 * Zoom levels and controls
 * Compass
 * ScaleBar
 * Cluster Pin colors
 * Location update settings
 */
private void setUpMapIfNeeded() {

    // Check if we were successful in obtaining the map.
    mMap.setBuiltInZoomControls(true);
    mMap.setMultiTouchControls(true);
    mMap.setMinZoomLevel(3);
    mMap.setMaxZoomLevel(19); // Latest OSM can go to 21!
    mMap.getTileProvider().createTileCache();
    mCompassOverlay = new CompassOverlay(this, new InternalCompassOrientationProvider(this), mMap);

    ScaleBarOverlay mScaleBarOverlay = new ScaleBarOverlay(this);
    mScaleBarOverlay.setScaleBarOffset(getResources().getDisplayMetrics().widthPixels / 2, 10);
    mScaleBarOverlay.setCentred(true);

    // Sets cluster pin color
    mCellTowerGridMarkerClusterer = new CellTowerGridMarkerClusterer(MapViewerOsmDroid.this);
    //BitmapDrawable mapPinDrawable = (BitmapDrawable) getResources().getDrawable(R.drawable.ic_map_pin_orange);
    BitmapDrawable mapPinDrawable = (BitmapDrawable) ResourcesCompat.getDrawable(getResources(),R.drawable.ic_map_pin_orange, null);

    mCellTowerGridMarkerClusterer.setIcon(mapPinDrawable == null ? null : mapPinDrawable.getBitmap());

    GpsMyLocationProvider gpsMyLocationProvider = new GpsMyLocationProvider(MapViewerOsmDroid.this.getBaseContext());
    gpsMyLocationProvider.setLocationUpdateMinDistance(100); // [m]  // Set the minimum distance for location updates
    gpsMyLocationProvider.setLocationUpdateMinTime(10000);   // [ms] // Set the minimum time interval for location updates
    mMyLocationOverlay = new MyLocationNewOverlay(MapViewerOsmDroid.this.getBaseContext(), gpsMyLocationProvider, mMap);
    mMyLocationOverlay.setDrawAccuracyEnabled(true);

    mMap.getOverlays().add(mCellTowerGridMarkerClusterer);
    mMap.getOverlays().add(mMyLocationOverlay);
    mMap.getOverlays().add(mCompassOverlay);
    mMap.getOverlays().add(mScaleBarOverlay);
}