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


Java Mapbox类代码示例

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


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

示例1: fetchRoute

import com.mapbox.mapboxsdk.Mapbox; //导入依赖的package包/类
/**
 * Requests a new {@link DirectionsRoute}.
 * <p>
 * Will use {@link Location} bearing if we have a rawLocation with bearing.
 *
 * @param origin      start point
 * @param destination end point
 */
private void fetchRoute(Point origin, Point destination) {
  if (origin != null && destination != null) {

    Double bearing = null;
    if (rawLocation != null) {
      bearing = rawLocation.hasBearing() ? Float.valueOf(rawLocation.getBearing()).doubleValue() : null;
    }

    NavigationRoute.builder()
      .accessToken(Mapbox.getAccessToken())
      .origin(origin, bearing, 90d)
      .voiceUnits(unitType)
      .profile(routeProfile)
      .language(language)
      .destination(destination).build().getRoute(this);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:26,代码来源:RouteViewModel.java

示例2: onCreate

import com.mapbox.mapboxsdk.Mapbox; //导入依赖的package包/类
@Override
public void onCreate() {
  super.onCreate();

  // Leak canary
  if (LeakCanary.isInAnalyzerProcess(this)) {
    return;
  }
  LeakCanary.install(this);

  if (BuildConfig.DEBUG) {
    Timber.plant(new Timber.DebugTree());
  }

  // Set access token
  String mapboxAccessToken = Utils.getMapboxAccessToken(getApplicationContext());
  if (TextUtils.isEmpty(mapboxAccessToken) || mapboxAccessToken.equals(DEFAULT_MAPBOX_ACCESS_TOKEN)) {
    Log.w(LOG_TAG, "Warning: access token isn't set.");
  }

  Mapbox.getInstance(getApplicationContext(), mapboxAccessToken);
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:23,代码来源:NavigationApplication.java

示例3: getMapboxAccessToken

import com.mapbox.mapboxsdk.Mapbox; //导入依赖的package包/类
/**
 * <p>
 * Returns the Mapbox access token set in the app resources.
 * </p>
 * It will first search for a token in the Mapbox object. If not found it
 * will then attempt to load the access token from the
 * {@code res/values/dev.xml} development file.
 *
 * @param context The {@link Context} of the {@link android.app.Activity} or {@link android.app.Fragment}.
 * @return The Mapbox access token or null if not found.
 */
public static String getMapboxAccessToken(@NonNull Context context) {
  try {
    // Read out AndroidManifest
    String token = Mapbox.getAccessToken();
    if (token == null || token.isEmpty()) {
      throw new IllegalArgumentException();
    }
    return token;
  } catch (Exception exception) {
    // Use fallback on string resource, used for development
    int tokenResId = context.getResources()
      .getIdentifier("mapbox_access_token", "string", context.getPackageName());
    return tokenResId != 0 ? context.getString(tokenResId) : null;
  }
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:27,代码来源:Utils.java

示例4: onCreate

import com.mapbox.mapboxsdk.Mapbox; //导入依赖的package包/类
@Override
public void onCreate() {
  super.onCreate();
  if (LeakCanary.isInAnalyzerProcess(this)) {
    // This process is dedicated to LeakCanary for heap analysis.
    // You should not init your app in this process.
    return;
  }

  if (BuildConfig.DEBUG) {
    Timber.plant(new Timber.DebugTree());
  }

  LeakCanary.install(this);
  initializeLogger();
  Mapbox.getInstance(this, getString(R.string.mapbox_access_token));
  Timber.plant(new Timber.DebugTree());

  // TODO remove when 5.2.1 is released
  FileSource.getInstance(this).activate();
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:22,代码来源:PluginApplication.java

示例5: onCreate

import com.mapbox.mapboxsdk.Mapbox; //导入依赖的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 account manager
  setContentView(R.layout.activity_simple_mapview);

  mapView = (MapView) findViewById(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {

      // Customize map with markers, polylines, etc.
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:22,代码来源:SimpleMapViewActivity.java

示例6: onCreate

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

  mapView = (MapView) findViewById(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {
      map = mapboxMap;

    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:22,代码来源:LanguageSwitchActivity.java

示例7: onCreate

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

  mapView = (MapView) findViewById(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {

      // Customize map with markers, polylines, etc.

    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:23,代码来源:MapboxStudioStyleActivity.java

示例8: onCreate

import com.mapbox.mapboxsdk.Mapbox; //导入依赖的package包/类
@Override
public 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_style_default);

  mapView = (MapView) findViewById(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {
      DefaultStyleActivity.this.mapboxMap = mapboxMap;

      // customize map with markers, polylines, etc

    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:24,代码来源:DefaultStyleActivity.java

示例9: onCreate

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

  Toast.makeText(ClickOnLayerActivity.this, R.string.click_on_polygon_toast_instruction,
    Toast.LENGTH_SHORT).show();

  mapView = findViewById(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(this);
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:19,代码来源:ClickOnLayerActivity.java

示例10: onCreate

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

  mapView = (MapView) findViewById(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {

      // Customize map with markers, polylines, etc.

    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:23,代码来源:SimpleMapViewActivity.java

示例11: onCreate

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

  mapView = (MapView) findViewById(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {
      MarathonExtrusionActivity.this.mapboxMap = mapboxMap;

      // Add the marathon route source to the map
      GeoJsonSource courseRouteGeoJson = new GeoJsonSource("coursedata", loadJsonFromAsset("marathon_route.geojson"));
      mapboxMap.addSource(courseRouteGeoJson);
      addExtrusionsLayerToMap();
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:26,代码来源:MarathonExtrusionActivity.java

示例12: onCreate

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

  mapView = (MapView) findViewById(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(@NonNull final MapboxMap map) {
      mapboxMap = map;
      setupBuildingExtrusionPlugin();
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:22,代码来源:RotationExtrusionActivity.java

示例13: onCreate

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

  setContentView(R.layout.activity_extrusion_light);

  mapView = (MapView) findViewById(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(@NonNull final MapboxMap map) {
      mapboxMap = map;
      setupBuildings();
      setupLight();
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:22,代码来源:AdjustExtrusionLightActivity.java

示例14: onCreate

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

  mapView = (MapView) findViewById(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {
      addClusteredGeoJsonSource(mapboxMap);
    }
  });
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:21,代码来源:CreateHotspotsActivity.java

示例15: onCreate

import com.mapbox.mapboxsdk.Mapbox; //导入依赖的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 account manager
  setContentView(R.layout.activity_style_rainfall);

  handler = new Handler();
  mapView = (MapView) findViewById(R.id.mapView);
  mapView.onCreate(savedInstanceState);
  mapView.getMapAsync(this);
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:17,代码来源:AddRainFallStyleActivity.java


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