本文整理汇总了Java中com.mapbox.mapboxsdk.maps.MapView.getMapAsync方法的典型用法代码示例。如果您正苦于以下问题:Java MapView.getMapAsync方法的具体用法?Java MapView.getMapAsync怎么用?Java MapView.getMapAsync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mapbox.mapboxsdk.maps.MapView
的用法示例。
在下文中一共展示了MapView.getMapAsync方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的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
}
});
}
示例2: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的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_annotation_marker);
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
mapboxMap.addMarker(new MarkerOptions()
.position(new LatLng(48.13863, 11.57603))
.title(getString(R.string.draw_marker_options_title))
.snippet(getString(R.string.draw_marker_options_snippet)));
}
});
}
示例3: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的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_lab_marker_following_route);
// Initialize the map view
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
map = mapboxMap;
// Load and Draw the GeoJSON. The marker animation is also handled here.
new DrawGeoJson().execute();
}
});
}
示例4: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的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();
}
});
}
示例5: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的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);
}
});
}
示例6: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.M)
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_map);
// MapBox
Mapbox.getInstance(this, getString(R.string.map_box_token));
mMapView = (MapView) findViewById(R.id.mapView);
mMapView.onCreate(savedInstanceState);
mMapView.getMapAsync(this);
requestPermissions();
mSelectLocationBt = (Button) findViewById(R.id.selectLocationBt);
mSelectLocationBt.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent returnIntent = new Intent();
returnIntent.putExtra("lat", mCurrentLocation.getLatitude());
returnIntent.putExtra("lng", mCurrentLocation.getLongitude());
setResult(Activity.RESULT_OK, returnIntent);
finish();
}
});
}
示例7: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_compass_listener);
ButterKnife.bind(this);
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
}
示例8: onViewCreated
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的package包/类
@Override
public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
mMapView = (MapView) view.findViewById(R.id.mapview);
mLocService = LocationServices.getLocationServices(getActivity());
mMapView.onCreate(savedInstanceState);
mMapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
mMap = mapboxMap;
mMap.setOnMyLocationChangeListener(FragMap.this);
mMap.setMyLocationEnabled(true);
if (mMap.getMyLocation() != null)
onMyLocationChange(mMap.getMyLocation());
mMap.addMarker(new MarkerOptions().position(mKaabePos).setIcon(IconFactory.getInstance(getActivity()).fromResource(R.drawable.ic_kaabe)));
FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.myLocationButton);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mMap.getMyLocation() != null) {
mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(mMap.getMyLocation().getLatitude(), mMap.getMyLocation().getLongitude()), 15));
}
}
});
}
});
}
示例9: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapboxAccountManager.start(this, getString(R.string.access_token));
setContentView(R.layout.activity_main);
locationServices = LocationServices.getLocationServices(MainActivity.this);
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
map = mapboxMap;
// Check if user has granted location permission. If they haven't, we request it
// otherwise we enable location tracking.
if (!locationServices.areLocationPermissionsGranted()) {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_LOCATION);
} else {
enableLocationTracking();
}
}
});
imageButton = (ImageButton) findViewById(R.id.btnPokeball);
imageButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new AlertDialog.Builder(MainActivity.this)
.setTitle("MONSTER CAUGHT!")
.setPositiveButton("OK", null)
.show();
}
});
}
示例10: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
MapboxAccountManager.start(this, getString(R.string.access_token));
setContentView(R.layout.activity_main);
// Create a mapView
mapView = (MapView) findViewById(R.id.mapview);
mapView.onCreate(savedInstanceState);
// Add a MapboxMap
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
// Customize map with markers, polylines, etc.
// Local Style JSON in the Android `assets` folder
// mapboxMap.setStyleUrl("asset://mapbox-raster-v8.json");
mapboxMap.setStyleUrl("asset://styles/geography-class-local.json");
// Style JSON hosted on a server
// mapboxMap.setStyleUrl("https://www.mapbox.com/android-sdk/files/mapbox-raster-v8.json");
// Examples of built in Mapbox Styles
// mapboxMap.setStyleUrl(Style.MAPBOX_STREETS);
// mapboxMap.setStyleUrl(Style.OUTDOORS);
// mapboxMap.setStyleUrl(Style.LIGHT);
// mapboxMap.setStyleUrl(Style.DARK);
}
});
}
示例11: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable 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_indoor_3d_map);
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(final MapboxMap mapboxMap) {
map = mapboxMap;
GeoJsonSource roomDataSource = new GeoJsonSource("room-data", loadJsonFromAsset("indoor-3d-map.geojson"));
map.addSource(roomDataSource);
FillExtrusionLayer roomExtrusionLayer = new FillExtrusionLayer("room-extrusion", "room-data");
roomExtrusionLayer.setProperties(
fillExtrusionColor(Function.property("color", new IdentityStops<String>())),
fillExtrusionHeight(Function.property("height", new IdentityStops<Float>())),
fillExtrusionBase(Function.property("base_height", new IdentityStops<Float>())),
fillExtrusionOpacity(0.5f)
);
map.addLayer(roomExtrusionLayer);
}
});
}
示例12: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的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_multiple_geometries);
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
}
示例13: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的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_zoom_dependent_fill_color);
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(final MapboxMap mapboxMap) {
FillLayer layer = mapboxMap.getLayerAs("water");
if (layer == null) {
return;
}
//Set a zoom function to update the color of the water
layer.setProperties(fillColor(Function.zoom(exponential(
Stop.stop(1f, fillColor(Color.GREEN)),
Stop.stop(8.5f, fillColor(Color.BLUE)),
Stop.stop(10f, fillColor(Color.RED)),
Stop.stop(18f, fillColor(Color.YELLOW))
))));
mapboxMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(40.73581, -73.99155), 12), 12000);
}
});
}
示例14: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的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_choropleth_json_vector_mix);
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
}
示例15: onCreate
import com.mapbox.mapboxsdk.maps.MapView; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable 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_lab_los_angeles_tourism);
mapView = (MapView) findViewById(R.id.mapView);
mapView.onCreate(savedInstanceState);
mapView.getMapAsync(this);
}