当前位置: 首页>>代码示例>>Java>>正文


Java CameraPosition类代码示例

本文整理汇总了Java中com.mapbox.mapboxsdk.camera.CameraPosition的典型用法代码示例。如果您正苦于以下问题:Java CameraPosition类的具体用法?Java CameraPosition怎么用?Java CameraPosition使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CameraPosition类属于com.mapbox.mapboxsdk.camera包,在下文中一共展示了CameraPosition类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildCameraPositionFromLocation

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
/**
 * Creates a camera position based on the given location.
 * <p>
 * From the {@link Location}, a target position is created.
 * Then using a preset tilt and zoom (based on screen orientation), a {@link CameraPosition} is built.
 *
 * @param location used to build the camera position
 * @return camera position to be animated to
 */
@NonNull
private CameraPosition buildCameraPositionFromLocation(Location location) {
  Point targetPoint = TurfMeasurement.destination(
    Point.fromLngLat(location.getLongitude(), location.getLatitude()),
    targetDistance, location.getBearing(), TurfConstants.UNIT_METERS
  );

  LatLng target = new LatLng(
    targetPoint.latitude(),
    targetPoint.longitude()
  );

  return new CameraPosition.Builder()
    .tilt(CAMERA_TILT)
    .zoom(CAMERA_ZOOM)
    .target(target)
    .bearing(location.getBearing())
    .build();
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:29,代码来源:NavigationCamera.java

示例2: onCameraIdle

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
/**
 * Might re-cluster.
 */
@Override
public void onCameraIdle() {
  Timber.d("OnCamerIdle");
  if (mRenderer instanceof MapboxMap.OnCameraIdleListener) {
    ((MapboxMap.OnCameraIdleListener) mRenderer).onCameraIdle();
  }

  // Don't re-compute clusters if the map has just been panned/tilted/rotated.
  CameraPosition position = mMap.getCameraPosition();
  if (mPreviousCameraPosition != null && mPreviousCameraPosition.zoom == position.zoom) {
    return;
  }
  mPreviousCameraPosition = mMap.getCameraPosition();
  Timber.e("OnCluster");
  cluster();
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:20,代码来源:ClusterManagerPlugin.java

示例3: onMapReady

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
@Override
public void onMapReady(final MapboxMap mapboxMap) {
  LocationEngine locationEngine = new LostLocationEngine(this);
  locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, locationEngine);
  locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.COMPASS);
  locationLayerPlugin.addCompassListener(new CompassListener() {
    @Override
    public void onCompassChanged(float userHeading) {
      CameraPosition cameraPosition = new CameraPosition.Builder().bearing(userHeading).build();
      mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
    }

    @Override
    public void onCompassAccuracyChange(int compassStatus) {
      System.out.println(compassStatus);
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:19,代码来源:CompassListenerActivity.java

示例4: recenterMap

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
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));
        }
    });
}
 
开发者ID:DaylightingSociety,项目名称:WhereAreTheEyes,代码行数:25,代码来源:MainActivity.java

示例5: recenterCamera

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
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);
        }
    });
}
 
开发者ID:DaylightingSociety,项目名称:WhereAreTheEyes,代码行数:17,代码来源:MainActivity.java

示例6: onLocationChanged

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
@Override
public void onLocationChanged(Location location) {
    // Store the new location
    mCurrentLocation = location;

    Log.i(this.getClass().getSimpleName(), "Latitude is: " + String.valueOf(mCurrentLocation.getLatitude()));
    Log.i(this.getClass().getSimpleName(), "Longitude is: " + String.valueOf(mCurrentLocation.getLongitude()));

    if (mCurrentLocation != null) {
        // Move the map camera to where the user location is
        mMap.setCameraPosition(new CameraPosition.Builder()
                .target(new LatLng(location))
                .build());

        // TODO update current location layer on map

    }

    // TODO do this on a separate thread or updating of location is blocked
    String queryGeometry = buildQueryGeometry(mCurrentLocation);
    queryOccurrence(queryGeometry);

}
 
开发者ID:jtklein,项目名称:2016GBIFchallenge,代码行数:24,代码来源:SgActivityMap.java

示例7: onResume

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
@Override
public void onResume() {
    super.onResume();
    mapView.onResume();
    if (mapboxMap != null) {
        switchMode(MapMode.DEFAULT);
        presenter.setForceRefreshPoi();
        presenter.setForceRefreshNotes();
        presenter.loadPoisIfNeeded();
        nextTuto(2);
        double lat = sharedPreferences.getFloat("latitude", 0);
        double lon = sharedPreferences.getFloat("longitude", 0);
        if (lat != 0 && lon != 0) {
            CameraPosition cameraPosition = new CameraPosition.Builder().target(new LatLng(lat, lon)).zoom(mapboxMap.getCameraPosition().zoom).build();
            mapboxMap.setCameraPosition(cameraPosition);
        } else {
            getUserLocation();
        }
    }
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:21,代码来源:MapFragment.java

示例8: onMapClick

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
@Override
public void onMapClick(@NonNull LatLng point) {

  // Toast instructing user to tap on the map
  Toast.makeText(
    AnimateMapCameraActivity.this,
    getString(R.string.tap_on_map_instruction),
    Toast.LENGTH_LONG
  ).show();

  CameraPosition position = new CameraPosition.Builder()
    .target(new LatLng(51.50550, -0.07520)) // Sets the new camera position
    .zoom(17) // Sets the zoom
    .bearing(180) // Rotate the camera
    .tilt(30) // Set the camera tilt
    .build(); // Creates a CameraPosition from the builder

  mapboxMap.animateCamera(CameraUpdateFactory
    .newCameraPosition(position), 7000);
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:21,代码来源:AnimateMapCameraActivity.java

示例9: onCreate

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  // Mapbox access token is configured here. This needs to be called either in your application
  // object or in the same activity which contains the mapview.
  Mapbox.getInstance(this, getString(R.string.access_token));

  // Configure initial map state
  MapboxMapOptions options = new MapboxMapOptions()
    .attributionTintColor(RED_COLOR)
    .compassFadesWhenFacingNorth(false)
    .styleUrl(Style.MAPBOX_STREETS)
    .camera(new CameraPosition.Builder()
      .target(new LatLng(25.255377, 55.3089185))
      .zoom(11.86)
      .tilt(10)
      .build());

  mapView = new MapView(this, options);
  mapView.setId(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(this);
  setContentView(mapView);
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:26,代码来源:PolygonHolesActivity.java

示例10: onMapMoved

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
@Override
public void onMapMoved(final CameraPosition mainMapCameraPosition) {

  cameraPositionForFragmentMap = new CameraPosition.Builder()
    .target(mainMapCameraPosition.target)
    .zoom(mainMapCameraPosition.zoom - ZOOM_DISTANCE_BETWEEN_MAIN_AND_FRAGMENT_MAPS)
    .bearing(mainMapCameraPosition.bearing)
    .tilt(mainMapCameraPosition.tilt)
    .build();

  fragmentMap.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(final MapboxMap mapInFragment) {
      mapInFragment.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPositionForFragmentMap));
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:18,代码来源:InsetMapActivity.java

示例11: animateCameraToSelection

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
/**
 * Animate camera to a feature.
 *
 * @param feature the feature to animate to
 */
private void animateCameraToSelection(Feature feature, double newZoom) {
  CameraPosition cameraPosition = mapboxMap.getCameraPosition();

  if (animatorSet != null) {
    animatorSet.cancel();
  }

  animatorSet = new AnimatorSet();
  animatorSet.playTogether(
    createLatLngAnimator(cameraPosition.target, convertToLatLng(feature)),
    createZoomAnimator(cameraPosition.zoom, newZoom),
    createBearingAnimator(cameraPosition.bearing, feature.getNumberProperty("bearing").doubleValue()),
    createTiltAnimator(cameraPosition.tilt, feature.getNumberProperty("tilt").doubleValue())
  );
  animatorSet.start();
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:22,代码来源:SymbolLayerMapillaryActivity.java

示例12: animateCameraToPosition

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
/**
 * Will animate the {@link MapboxMap} to the given {@link CameraPosition}
 * with a 2 second duration.
 * <p>
 * If a user interacts with the {@link MapboxMap} while the animation is in progress,
 * the animation will be cancelled.  So it's important to add the {@link ProgressChangeListener}
 * in both onCancel() and onFinish() scenarios.
 *
 * @param position to which the camera should animate
 */
private void animateCameraToPosition(CameraPosition position) {
  mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 2000,
    new MapboxMap.CancelableCallback() {
      @Override
      public void onCancel() {
        navigation.addProgressChangeListener(NavigationCamera.this);
      }

      @Override
      public void onFinish() {
        navigation.addProgressChangeListener(NavigationCamera.this);
      }
    });
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:25,代码来源:NavigationCamera.java

示例13: buildCameraPositionFromRoute

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
/**
 * Creates a camera position based on the given route.
 * <p>
 * From the {@link DirectionsRoute}, an initial bearing and target position are created.
 * Then using a preset tilt and zoom (based on screen orientation), a {@link CameraPosition} is built.
 *
 * @param route used to build the camera position
 * @return camera position to be animated to
 */
@NonNull
private CameraPosition buildCameraPositionFromRoute(DirectionsRoute route) {
  LineString lineString = LineString.fromPolyline(route.geometry(), Constants.PRECISION_6);

  double initialBearing = TurfMeasurement.bearing(
    Point.fromLngLat(
      lineString.getCoordinates().get(0).getLongitude(), lineString.getCoordinates().get(0).getLatitude()
    ),
    Point.fromLngLat(
      lineString.getCoordinates().get(1).getLongitude(), lineString.getCoordinates().get(1).getLatitude()
    )
  );

  Point targetPoint = TurfMeasurement.destination(
    Point.fromLngLat(
      lineString.getCoordinates().get(0).getLongitude(), lineString.getCoordinates().get(0).getLatitude()
    ),
    targetDistance, initialBearing, TurfConstants.UNIT_METERS
  );

  LatLng target = new LatLng(
    targetPoint.latitude(),
    targetPoint.longitude()
  );

  return new CameraPosition.Builder()
    .tilt(CAMERA_TILT)
    .zoom(CAMERA_ZOOM)
    .target(target)
    .bearing(initialBearing)
    .build();
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:42,代码来源:NavigationCamera.java

示例14: onProgressChange

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
@Override
public void onProgressChange(Location location, RouteProgress routeProgress) {
  if (tracking) {
    locationLayerPlugin.forceLocationUpdate(location);
    CameraPosition cameraPosition = new CameraPosition.Builder()
      .zoom(15)
      .target(new LatLng(location.getLatitude(), location.getLongitude()))
      .bearing(location.getBearing())
      .build();
    mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition), 2000);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:13,代码来源:RerouteActivity.java

示例15: setupUI

import com.mapbox.mapboxsdk.camera.CameraPosition; //导入依赖的package包/类
private void setupUI(final OfflineTilePyramidRegionDefinition definition) {
  // update map
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {
      // correct style
      mapboxMap.setStyle(definition.getStyleURL());

      // position map on top of offline region
      CameraPosition cameraPosition = OfflineUtils.getCameraPosition(definition);
      mapboxMap.moveCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));

      // restrict camera movement
      mapboxMap.setMinZoomPreference(definition.getMinZoom());
      mapboxMap.setMaxZoomPreference(definition.getMaxZoom());
      mapboxMap.setLatLngBoundsForCameraTarget(definition.getBounds());
    }
  });

  // update textview data
  nameView.setText(OfflineUtils.convertRegionName(offlineRegion.getMetadata()));
  styleView.setText(definition.getStyleURL());
  latLngBoundsView.setText(definition.getBounds().toString());
  minZoomView.setText(String.valueOf(definition.getMinZoom()));
  maxZoomView.setText(String.valueOf(definition.getMaxZoom()));
  offlineRegion.getStatus(offlineRegionStatusCallback);
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:28,代码来源:OfflineRegionDetailActivity.java


注:本文中的com.mapbox.mapboxsdk.camera.CameraPosition类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。