本文整理汇总了Java中com.mapbox.mapboxsdk.maps.MapboxMap类的典型用法代码示例。如果您正苦于以下问题:Java MapboxMap类的具体用法?Java MapboxMap怎么用?Java MapboxMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapboxMap类属于com.mapbox.mapboxsdk.maps包,在下文中一共展示了MapboxMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onMapReady
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的package包/类
/**
* Fired after the map is ready, this is our cue to finish
* setting up the rest of the plugins / location engine.
* <p>
* Also, we check for launch data (coordinates or route).
*
* @param mapboxMap used for route, camera, and location UI
* @since 0.6.0
*/
@Override
public void onMapReady(MapboxMap mapboxMap) {
map = mapboxMap;
map.setPadding(0, 0, 0, summaryBottomSheet.getHeight());
ThemeSwitcher.setMapStyle(getContext(), map, new MapboxMap.OnStyleLoadedListener() {
@Override
public void onStyleLoaded(String style) {
initRoute();
initLocationLayer();
initLifecycleObservers();
initNavigationPresenter();
initClickListeners();
map.addOnScrollListener(NavigationView.this);
onNavigationReadyCallback.onNavigationReady();
}
});
}
示例2: updateMapSourceFromFeatureCollection
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的package包/类
/**
* Takes a {@link FeatureCollection} and creates a map GeoJson source using the sourceId also
* provided.
*
* @param mapboxMap that the current mapView is using
* @param collection the feature collection to be added to the map style
* @param sourceId the source's id for identifying it when adding layers
* @since 0.8.0
*/
public static void updateMapSourceFromFeatureCollection(@NonNull MapboxMap mapboxMap,
@Nullable FeatureCollection collection,
@NonNull String sourceId) {
if (collection == null) {
collection = FeatureCollection.fromFeatures(new Feature[] {});
}
GeoJsonSource source = mapboxMap.getSourceAs(sourceId);
if (source == null) {
GeoJsonOptions routeGeoJsonOptions = new GeoJsonOptions().withMaxZoom(16);
GeoJsonSource routeSource = new GeoJsonSource(sourceId, collection, routeGeoJsonOptions);
mapboxMap.addSource(routeSource);
} else {
source.setGeoJson(collection);
}
}
示例3: onMapChangeLocationLayerRedrawn
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的package包/类
@Test
public void onMapChangeLocationLayerRedrawn() throws Exception {
executeLocationLayerTest(new LocationLayerPluginAction.onPerformLocationLayerAction() {
@Override
public void onLocationLayerAction(LocationLayerPlugin locationLayerPlugin, MapboxMap mapboxMap,
UiController uiController) {
locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.TRACKING);
assertTrue(mapboxMap.getLayer(FOREGROUND_LAYER) != null);
mapboxMap.setStyleUrl(Style.SATELLITE);
uiController.loopMainThreadForAtLeast(500);
assertEquals(locationLayerPlugin.getLocationLayerMode(), LocationLayerMode.TRACKING);
assertTrue(mapboxMap.getLayer(FOREGROUND_LAYER) != null);
assertTrue(mapboxMap.getLayer(FOREGROUND_LAYER).getVisibility().getValue()
.equals(Property.VISIBLE));
}
});
}
示例4: onMapReady
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的package包/类
@Override
public void onMapReady(MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
locationLayerPlugin = new LocationLayerPlugin(mapView, mapboxMap, null);
locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.NAVIGATION);
navigationMapRoute = new NavigationMapRoute(navigation, mapView, mapboxMap);
mapboxMap.setOnMapClickListener(this);
Snackbar.make(mapView, "Tap map to place waypoint", BaseTransientBottomBar.LENGTH_LONG).show();
locationEngine = new MockLocationEngine(1000, 50, true);
mapboxMap.setLocationSource(locationEngine);
newOrigin();
}
示例5: onCameraIdle
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的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();
}
示例6: onMapReady
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的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);
}
});
}
示例7: onMapReady
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的package包/类
@Override
public void onMapReady(MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
this.mapboxMap.setOnInfoWindowClickListener(new MapboxMap.OnInfoWindowClickListener() {
@Override
public boolean onInfoWindowClick(@NonNull Marker marker) {
for (Acopio acopio: acopios) {
if (acopio.getNombre().equals(marker.getTitle())) {
Intent intent = new Intent(context, ActivityAcopio.class);
intent.putExtra("acopio", acopio);
startActivity(intent);
break;
}
}
return true;
}
});
getAcopios();
}
示例8: locationBearingLayersAdded
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的package包/类
@Test
public void locationBearingLayersAdded() throws Exception {
executeLocationLayerTest(new LocationLayerPluginAction.onPerformLocationLayerAction() {
@Override
public void onLocationLayerAction(LocationLayerPlugin locationLayerPlugin, MapboxMap mapboxMap,
UiController uiController) {
locationLayerPlugin.setLocationLayerEnabled(LocationLayerMode.COMPASS);
assertTrue(mapboxMap.getLayer(ACCURACY_LAYER) != null);
assertTrue(mapboxMap.getLayer(BACKGROUND_LAYER) != null);
assertTrue(mapboxMap.getLayer(FOREGROUND_LAYER) != null);
assertTrue(mapboxMap.getLayer(BEARING_LAYER) != null);
}
});
}
示例9: lineCapSecondaryBaseLayer
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的package包/类
@Test
public void lineCapSecondaryBaseLayer() throws Exception {
executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
@Override
public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
assertEquals(ROUND, ((LineLayer) mapboxMap.getLayerAs(Secondary.BASE_LAYER_ID)).getLineCap().getValue());
}
});
}
示例10: animateCameraToPosition
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的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);
}
});
}
示例11: lineJoinLocalBaseLayer
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的package包/类
@Test
public void lineJoinLocalBaseLayer() throws Exception {
executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
@Override
public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
assertEquals(ROUND, ((LineLayer) mapboxMap.getLayerAs(Local.BASE_LAYER_ID)).getLineJoin().getValue());
}
});
}
示例12: lineWidthFunctionMotorwayCaseLayer
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的package包/类
@Test
public void lineWidthFunctionMotorwayCaseLayer() throws Exception {
executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
@Override
public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
LineLayer layer = mapboxMap.getLayerAs(MotorWay.CASE_LAYER_ID);
assertNotNull(layer.getLineWidth());
assertNotNull(layer.getLineWidth().getFunction());
assertEquals(CameraFunction.class, layer.getLineWidth().getFunction().getClass());
assertEquals(ExponentialStops.class, layer.getLineWidth().getFunction().getStops().getClass());
assertEquals(1.5f, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).getBase(), 0.001);
assertEquals(4, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).size());
}
});
}
示例13: lineWidthFunctionLocalBaseLayer
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的package包/类
@Test
public void lineWidthFunctionLocalBaseLayer() throws Exception {
executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
@Override
public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
LineLayer layer = mapboxMap.getLayerAs(Local.BASE_LAYER_ID);
assertNotNull(layer.getLineWidth());
assertNotNull(layer.getLineWidth().getFunction());
assertEquals(CameraFunction.class, layer.getLineWidth().getFunction().getClass());
assertEquals(ExponentialStops.class, layer.getLineWidth().getFunction().getStops().getClass());
assertEquals(1.5f, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).getBase(), 0.001);
assertEquals(2, ((ExponentialStops) layer.getLineWidth().getFunction().getStops()).size());
}
});
}
示例14: lineCapLocalBaseLayer
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的package包/类
@Test
public void lineCapLocalBaseLayer() throws Exception {
executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
@Override
public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
assertEquals(ROUND, ((LineLayer) mapboxMap.getLayerAs(Local.BASE_LAYER_ID)).getLineCap().getValue());
}
});
}
示例15: reattachSecondaryCaseWithLoadNewStyle
import com.mapbox.mapboxsdk.maps.MapboxMap; //导入依赖的package包/类
@Test
public void reattachSecondaryCaseWithLoadNewStyle() throws Exception {
executeTrafficTest(new TrafficPluginAction.OnPerformTrafficAction() {
@Override
public void onTrafficAction(TrafficPlugin trafficPlugin, MapboxMap mapboxMap, UiController controller) {
mapboxMap.setStyleUrl(Style.DARK);
controller.loopMainThreadForAtLeast(500);
assertTrue(mapboxMap.getLayer(Secondary.CASE_LAYER_ID) != null);
}
});
}