com.mapbox.mapboxsdk.maps.OnMapReadyCallback Java Examples
The following examples show how to use
com.mapbox.mapboxsdk.maps.OnMapReadyCallback.
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: MainActivity.java From WhereAreTheEyes with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void setMapTracking() { final String trackingPref = getTrackingPreference(); mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(MapboxMap mapboxMap) { TrackingSettings tracking = mapboxMap.getTrackingSettings(); switch(trackingPref) { case "position": tracking.setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW); tracking.setMyBearingTrackingMode(MyBearingTracking.NONE); break; case "direction": tracking.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE); tracking.setMyBearingTrackingMode(MyBearingTracking.COMPASS); break; case "movement": tracking.setMyBearingTrackingMode(MyLocationTracking.TRACKING_NONE); tracking.setMyLocationTrackingMode(MyBearingTracking.GPS); break; } } }); }
Example #2
Source File: MainActivity.java From WhereAreTheEyes with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void recenterMap() { final Location l = gps.getLocation(); // This shouldn't normally happen, but does on the Android emulator. // It only occurs if recenterMap is called before we receive our first // gps ping. We normally receive a ping within a second or two of app // launch, but *not* if the emulator only pings on demand. if( l == null ) return; mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(MapboxMap mapboxMap) { // We'll maintain zoom level and tilt, just want to change position CameraPosition old = mapboxMap.getCameraPosition(); CameraPosition pos = new CameraPosition.Builder() .target(new LatLng(l.getLatitude(), l.getLongitude())) .zoom(old.zoom) .tilt(old.tilt) .build(); mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(pos)); } }); }
Example #3
Source File: MainActivity.java From WhereAreTheEyes with BSD 3-Clause "New" or "Revised" License | 6 votes |
public void recenterCamera(View view) { mapView.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(MapboxMap mapboxMap) { Location loc = gps.getLocation(); if( loc == null ) return; CameraPosition position = new CameraPosition.Builder() .target(new LatLng(loc.getLatitude(), loc.getLongitude())) .zoom(17) .bearing(0) .build(); mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 3000); } }); }
Example #4
Source File: DownloadPinsTask.java From WhereAreTheEyes with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void renderPins(final PinData p) { // Note: Use a LinkedList here so we don't need contiguous memory // We were having some interesting memory problems with an ArrayList. final LinkedList<MarkerOptions> markers = new LinkedList<MarkerOptions>(); Iterator it = p.pins.entrySet().iterator(); while( it.hasNext() ) { Map.Entry pair = (Map.Entry)it.next(); final MarkerOptions marker = new MarkerOptions().position((LatLng)pair.getKey()); marker.title(p.map.getContext().getString(R.string.confirmations) + ": " + Integer.valueOf((int)pair.getValue()).toString()); marker.icon(Images.getCameraIcon()); marker.snippet("This is a camera."); markers.add(marker); } if( markers.size() != 0 ) { Log.d("GPS", "Trying to render pins: " + Integer.toString(markers.size())); Runnable clearPins = new Runnable() { public void run() { p.map.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(MapboxMap mapboxMap) { // We don't want to layer cameras on top mapboxMap.removeAnnotations(); mapboxMap.addMarkers(markers); Log.d("GPS", "Pins now on map: " + Integer.toString(mapboxMap.getAnnotations().size())); } }); } }; // Note: Pins *must* be cleared on the main thread. // This is because if a UI window (like the pin detail screen) is currently open // then only the thread that created it can destroy it. If we delete the pins from // the background while a UI window for the pin is open it crashes the app. Handler mainThread = new Handler(Looper.getMainLooper()); mainThread.post(clearPins); } }
Example #5
Source File: AirMapMapView.java From AirMapSDK-Android with Apache License 2.0 | 5 votes |
@Override public void getMapAsync(@NonNull final OnMapReadyCallback callback) { super.getMapAsync(mapboxMap -> { map = mapboxMap; map.addOnMapClickListener(AirMapMapView.this); map.getUiSettings().setLogoGravity(Gravity.BOTTOM | Gravity.END); // Move to bottom right map.getUiSettings().setAttributionGravity(Gravity.BOTTOM | Gravity.END); // Move to bottom right map.setPrefetchesTiles(true); mapStyleController.onMapReady(); callback.onMapReady(mapboxMap); }); }
Example #6
Source File: DCMapFragment.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
@Override public void onMapReady(@NonNull MapboxMap mapboxMap) { this.mapboxMap = mapboxMap; for (OnMapReadyCallback onMapReadyCallback : mapReadyCallbackList) { onMapReadyCallback.onMapReady(mapboxMap); } }
Example #7
Source File: DCMapFragment.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
/** * Sets a callback object which will be triggered when the MapboxMap instance is ready to be used. * * @param onMapReadyCallback The callback to be invoked. */ public void getMapAsync(@NonNull final OnMapReadyCallback onMapReadyCallback) { if (mapboxMap == null) { mapReadyCallbackList.add(onMapReadyCallback); } else { onMapReadyCallback.onMapReady(mapboxMap); } }