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


Java CameraUpdateFactory类代码示例

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


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

示例1: onMapReady

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的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

示例2: updateMainMarker

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的package包/类
private void updateMainMarker() {
    if (mMap != null && mPlace != null && mPlace.hasLocation()) {
        LatLng placeLocation = new LatLng(mPlace.getLocation().getLatitude(), mPlace.getLocation().getLongitude());
        if (mMainMarker == null) {
            mMainMarker = mMap.addMarker(new MarkerOptions()
                    .position(placeLocation)
                    .title(mPlace.getName()));
        } else {
            mMainMarker.setTitle(mPlace.getName() + "-updated");
            mMainMarker.setPosition(placeLocation);
            mMap.updateMarker(mMainMarker);
        }
        CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(placeLocation, MapFragment.DEFAULT_ZOOMLEVEL);
        mMap.moveCamera(cameraUpdate);
    }
}
 
开发者ID:Turistforeningen,项目名称:SjekkUT,代码行数:17,代码来源:PlaceFragment.java

示例3: recenterMap

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的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

示例4: recenterCamera

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的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

示例5: onMyLocationChange

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的package包/类
@Override
public void onMyLocationChange(@Nullable Location location) {
    LatLng pos = new LatLng(location.getLatitude(), location.getLongitude());
    if (mLine != null) {
        mMap.removePolyline(mLine);
        mMap.animateCamera(CameraUpdateFactory.newLatLng(pos));
    } else {
        //zoom first time
        mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 15));
    }


    mLine = mMap.addPolyline(new PolylineOptions()
            .add(pos)
            .add(mKaabePos)
            .color(Color.parseColor("#3bb2d0"))
            .width(3));


}
 
开发者ID:metinkale38,项目名称:prayer-times-android,代码行数:21,代码来源:FragMap.java

示例6: onAnimationUpdate

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的package包/类
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
    float animatedValue = (Float) valueAnimator.getAnimatedValue();
    int pixelToMove = (int) ((animatedValue - previousStep) * totalDist / 100);

    if (previousStep == 0) {
        Animation animation = new AlphaAnimation(0.0f, 1.0f);
        animation.setDuration(100);
        animation.setFillAfter(true);
        handImageView.startAnimation(animation);
    }
    if (animatedValue > STEPS_CENTER_ANIMATION / 2) {
        pixelToMove = -pixelToMove;
    }

    mapboxMap.moveCamera(CameraUpdateFactory.scrollBy(pixelToMove, 0));

    float left = handImageView.getX() + pixelToMove;
    handImageView.setX(left);


    previousStep = animatedValue;
}
 
开发者ID:jawg,项目名称:osm-contributor,代码行数:24,代码来源:OsmCreationAnimatorUpdateListener.java

示例7: onMapClick

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的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

示例8: onSensorChanged

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的package包/类
@Override
public void onSensorChanged(SensorEvent event) {
  if (event.sensor.getType() == Sensor.TYPE_ACCELEROMETER) {
    gravityArray = event.values;
  }
  if (event.sensor.getType() == Sensor.TYPE_MAGNETIC_FIELD) {
    magneticArray = event.values;
  }
  if (gravityArray != null && magneticArray != null) {
    boolean success = SensorManager.getRotationMatrix(rotationMatrix, inclinationMatrix, gravityArray, magneticArray);
    if (success) {
      if (mapboxMap != null) {
        int mapCameraAnimationMillisecondsSpeed = 100;
        mapboxMap.animateCamera(CameraUpdateFactory
          .newCameraPosition(createNewCameraPosition()), mapCameraAnimationMillisecondsSpeed
        );
      }
    }
  }
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:21,代码来源:RotationExtrusionActivity.java

示例9: onCreate

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的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));

  // This contains the MapView in XML and needs to be called after the access token is configured.
  setContentView(R.layout.activity_marker_clusters_plugin);

  mapView = (MapView) findViewById(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {
      MarkerClustersPluginActivity.this.mapboxMap = mapboxMap;
      mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(48.865539, 2.348603), 10.8),2800);

      // Initializing the cluster plugin
      clusterManagerPlugin = new ClusterManagerPlugin<>(MarkerClustersPluginActivity.this, mapboxMap);
      initCameraListener();
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:26,代码来源:MarkerClustersPluginActivity.java

示例10: onMapMoved

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的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: resetCameraPosition

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的package包/类
/**
 * Enables tracking and moves the camera to the last known location update
 * from the {@link ProgressChangeListener}.
 *
 * @since 0.6.0
 */
public void resetCameraPosition() {
  this.trackingEnabled = true;
  if (currentCameraPosition != null) {
    mapboxMap.easeCamera(CameraUpdateFactory.newCameraPosition(currentCameraPosition), 750, true);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:13,代码来源:NavigationCamera.java

示例12: animateCameraToPosition

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的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: onProgressChange

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的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

示例14: newOrigin

import com.mapbox.mapboxsdk.camera.CameraUpdateFactory; //导入依赖的package包/类
private void newOrigin() {
  if (mapboxMap != null) {
    LatLng latLng = Utils.getRandomLatLng(new double[] {-77.1825, 38.7825, -76.9790, 39.0157});
    ((MockLocationEngine) locationEngine).setLastLocation(
      Point.fromLngLat(latLng.getLongitude(), latLng.getLatitude())
    );
    mapboxMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 12));
    mapboxMap.setMyLocationEnabled(true);
    mapboxMap.getTrackingSettings().setMyLocationTrackingMode(MyLocationTracking.TRACKING_FOLLOW);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:12,代码来源:MockNavigationActivity.java

示例15: onLocationChanged

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

    mMapboxMap.moveCamera(CameraUpdateFactory.newLatLng(
            new LatLng(location.getLatitude(), location.getLongitude())
    ));
}
 
开发者ID:VitorPoncell,项目名称:poturnoChat,代码行数:9,代码来源:MapActivity.java


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