本文整理汇总了Java中com.mapbox.mapboxsdk.views.MapView类的典型用法代码示例。如果您正苦于以下问题:Java MapView类的具体用法?Java MapView怎么用?Java MapView使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MapView类属于com.mapbox.mapboxsdk.views包,在下文中一共展示了MapView类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateView
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_nearby, container, false);
rootView.setPadding(0, getContentTopOffsetPx(getActivity()), 0, 0);
mapView = (MapView) rootView.findViewById(R.id.mapview);
mapView.setAccessToken(getString(R.string.mapbox_public_token));
markerIconPassive = mapView.getSpriteFactory().fromResource(R.drawable.ic_map_marker);
// TODO: pass savedInstanceState into mapView.onCreate once the MapView starts managing
// runtime permissions in a better way. This way, the MapView will start uninitialized
// so that we get a chance to query for runtime permissions before enabling the user's
// location in the MapView.
mapView.onCreate(null);
rootView.findViewById(R.id.user_location_button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
checkLocationPermissionsToGoToUserLocation();
}
});
return rootView;
}
示例2: executeSearch
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
public void executeSearch(Context context, MapView mapView, String value, View PB){
progressBar = PB;
progressBar.setVisibility(View.VISIBLE);
mv = mapView;
mapContext = context;
value = value.replace(" ", "%20");
String URI = "https://overpass-api.de/api/interpreter?" +
"data=[out:json][timeout:60];(" +
"node[\"name\"~\"" + value + "\",i]" + boundingBox +
"way[\"name\"~\"" + value + "\",i]" + boundingBox +
"relation[\"name\"~\"" + value + "\",i]" + boundingBox +
"node[\"ref\"~\"" + value + "\",i]" + boundingBox +
"way[\"ref\"~\"" + value + "\",i]" + boundingBox +
"relation[\"ref\"~\"" + value + "\",i]" + boundingBox +
");out%20center;>;out%20skel%20qt;";
mRequestQueue = Volley.newRequestQueue(context); // Create queue for volley
fetchJsonResponse(URI);
}
示例3: getBusStops
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
public List getBusStops(Context context, MapView mapView){
mapContext = context;
mv = mapView;
String URI = "https://overpass-api.de/api/interpreter?" +
"data=[out:json][timeout:25];(" +
"node[\"highway\"~\"" + "bus_stop" + "\",i]" + boundingBox +
"way[\"highway\"~\"" + "bus_stop" + "\",i]" + boundingBox +
"relation[\"highway\"~\"" + "bus_stop" + "\",i]" + boundingBox +
");out%20center;>;out%20skel%20qt;";
mRequestQueue = Volley.newRequestQueue(context); // Create queue for volley
fetchJsonResponse(URI);
// Finish up by storing the list in a list and return it
List<List> busStops = new ArrayList<>();
busStops.add(campusLoopStops);
return busStops;
}
示例4: onMapChanged
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
@Override
public void onMapChanged(int i) {
if (i == MapView.REGION_DID_CHANGE || i == MapView.REGION_DID_CHANGE_ANIMATED) {
// Refresh annotations when zoom level change
int z = (int) mMapView.getZoomLevel();
if (currentZoomLevel != z) {
currentZoomLevel = z;
Log.d(TAG, "Zoomlevel changed to " + currentZoomLevel);
runOnUiThread(new Thread(new Runnable() {
public void run() {
// Refresh annotations when zoom level change
refreshAnnotations();
}
}));
}
}
}
示例5: onCreate
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = this.getIntent();
String fileName = intent.getStringExtra(Intent.EXTRA_TEXT);
MapView mapView = new MapView(this);
BoundingBox box;
TileLayer mbTileLayer = new MBTilesLayer(this, fileName);
mapView.setTileSource(new ITileLayer[] {
mbTileLayer, new WebSourceTileLayer("mapquest",
"http://otile1.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png").setName(
"MapQuest Open Aerial")
.setAttribution("Tiles courtesy of MapQuest and OpenStreetMap contributors.")
.setMinimumZoomLevel(1)
.setMaximumZoomLevel(18)
});
box = mbTileLayer.getBoundingBox();
mapView.setScrollableAreaLimit(box);
mapView.setMinZoomLevel(mapView.getTileProvider().getMinimumZoomLevel());
mapView.setMaxZoomLevel(mapView.getTileProvider().getMaximumZoomLevel());
mapView.setCenter(mapView.getTileProvider().getCenterCoordinate());
mapView.setZoom(0);
Log.d("MapboxPlugin", "zoomToBoundingBox " + box.toString());
setContentView(mapView);
}
示例6: initFeatureBuilder
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
protected void initFeatureBuilder(MapView map) {
Resources res = this.getResources();
GradientDrawable vertexImg = (GradientDrawable) res.getDrawable(this.resource("drawable", "vertex_marker"));
// Pre-rendering images for the three states of vertex marker; default, selected and ghost.
vertexImg.setColor(Color.parseColor("#FFFFFF"));
Drawable vertexImage = new BitmapDrawable(res, MapEditorActivity.toBitmap(vertexImg));
vertexImg.setAlpha(60);
Drawable vertexMiddleImage = new BitmapDrawable(res, MapEditorActivity.toBitmap(vertexImg));
vertexImg.setAlpha(255);
vertexImg.setColor(Color.parseColor("#FFFF00"));
Drawable vertexSelectedImage = new BitmapDrawable(res, MapEditorActivity.toBitmap(vertexImg));
this.featureBuilder = new Builder(map);
this.featureBuilder.setVertexImage(vertexImage);
this.featureBuilder.setVertexMiddleImage(vertexMiddleImage);
this.featureBuilder.setVertexSelectedImage(vertexSelectedImage);
}
示例7: PolygonGeometry
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
public PolygonGeometry(MapView mv, Builder builder) {
this.mapView = mv;
this.builder = builder;
this.latLngs = new ArrayList<LatLng>();
this.outerRingStroke = new PathOverlay(this.lineColor, this.strokeWidth);
this.outerRingStroke.getPaint().setStyle(Paint.Style.STROKE);
this.outerRingStroke.getPaint().setAlpha(100);
this.outerRingStroke.getPaint().setStrokeWidth(3);
this.outerRingFill = new PathOverlay(this.lineColor, 0);
this.outerRingFill.getPaint().setStyle(Paint.Style.FILL);
this.outerRingFill.getPaint().setAlpha(50);
// Prevent glitching when panning & zooming map (see: https://github.com/mapbox/mapbox-android-sdk/issues/461).
this.outerRingStroke.setOptimizePath(false);
this.outerRingFill.setOptimizePath(false);
this.mapView.getOverlays().add(this.outerRingStroke);
this.mapView.getOverlays().add(this.outerRingFill);
}
示例8: getMyLocationMapDrawingBounds
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
protected RectF getMyLocationMapDrawingBounds(MapView mv, Location lastFix, RectF reuse) {
mv.getProjection().toMapPixels(mLatLng, mMapCoords);
reuse = getDrawingBounds(mMapCoords, lastFix, reuse);
// Add in the accuracy circle if enabled
if (mDrawAccuracyEnabled) {
final float radius = (float) Math.ceil(
lastFix.getAccuracy() / (float) Projection.groundResolution(
lastFix.getLatitude(), mMapView.getZoomLevel())
);
RectF accuracyRect =
new RectF(mMapCoords.x - radius, mMapCoords.y - radius, mMapCoords.x + radius,
mMapCoords.y + radius);
final float strokeWidth = (float) Math.ceil(
mCirclePaint.getStrokeWidth() == 0 ? 1 : mCirclePaint.getStrokeWidth());
accuracyRect.inset(-strokeWidth, -strokeWidth);
reuse.union(accuracyRect);
}
return reuse;
}
示例9: addToMap
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
public static void addToMap(Activity activity, MapView mapView) throws IOException, JSONException {
/**
* Deal with SharedPreferences. Use it if we haven't explicitly loaded. Set it if we have.
*/
SharedPreferences preferences = activity.getPreferences(Context.MODE_PRIVATE);
if (fpGeoJson == null) {
String previousFpGeoJsonPath = preferences.getString(PREVIOUS_FP_FILE_PATH, null);
if (previousFpGeoJsonPath == null) return;
load(new File(previousFpGeoJsonPath));
} else {
SharedPreferences.Editor editor = preferences.edit();
editor.putString(PREVIOUS_FP_FILE_PATH, fpGeoJson.getAbsolutePath());
editor.apply();
}
if (atlas == null) return;
atlas.setActivity(activity);
atlas.setupMapView(mapView);
}
示例10: MapTileDownloader
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
public MapTileDownloader(final ITileLayer pTileSource, final MapTileCache pTileCache,
final NetworkAvailabilityCheck pNetworkAvailabilityCheck, final MapView mapView) {
super(NUMBER_OF_TILE_DOWNLOAD_THREADS, TILE_DOWNLOAD_MAXIMUM_QUEUE_SIZE);
mMapView = mapView;
mUseDataConnection = true;
if (pTileSource instanceof MBTilesLayer) {
mUseDataConnection = false;
}
mTileCache.set(pTileCache);
hdpi = AppUtils.isRunningOn2xOrGreaterScreen(mapView.getContext());
Log.d(TAG, String.format("Going to use @2x tiles? '%b'", hdpi));
mNetworkAvailabilityCheck = pNetworkAvailabilityCheck;
setTileSource(pTileSource);
}
示例11: initializeMap
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
private void initializeMap() {
mapView.setStyleUrl("asset://mapstyle.json");
mapView.setMyLocationTrackingMode(MyLocationTracking.TRACKING_NONE);
mapView.setLogoVisibility(View.GONE);
mapView.setAttributionVisibility(View.GONE);
mapView.setOnMyLocationChangeListener(new MapView.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange(@Nullable Location location) {
makeUseOfNewLocation(location);
if (!firstLocationLock) {
goToUserLocation();
firstLocationLock = true;
}
}
});
mapView.setOnScrollListener(new MapView.OnScrollListener() {
@Override
public void onScroll() {
fetchNearbyPages();
}
});
mapView.setOnMarkerClickListener(new MapView.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(@NonNull Marker marker) {
NearbyPage page = findNearbyPageFromMarker(marker);
if (page != null) {
PageTitle title = new PageTitle(page.getTitle(), site, page.getThumblUrl());
((PageActivity) getActivity()).showLinkPreview(title, HistoryEntry.SOURCE_NEARBY, page.getLocation());
return true;
} else {
return false;
}
}
});
}
示例12: onCreate
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setStyleUrl("asset://sjc-imagery.json");
mapView.setCenterCoordinate(new LatLng(48.5, -123.0));
mapView.setZoomLevel(11);
mapView.onCreate(savedInstanceState);
}
示例13: getPOI
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
public List getPOI(Context context, MapView mapView){
// This method is executed to get all the point of interest listed below and within the
// bounding box. It's important to note that we only run this once when the main activity is
// created and save the results in a list.
mv = mapView;
mapContext = context;
String boundingBox = mapContext.getString(R.string.map_bounding_box);
String URI = "https://overpass-api.de/api/interpreter?" +
"data=[out:json][timeout:25];(" +
"node[\"amenity\"~\"atm\",i]" + boundingBox +
"node[\"amenity\"~\"bar\",i]" + boundingBox +
"node[\"amenity\"~\"emergency_phone\",i]" + boundingBox +
"node[\"amenity\"~\"fast_food\",i]" + boundingBox +
"way[\"amenity\"~\"fast_food\",i]" + boundingBox +
"node[\"amenity\"~\"library\",i]" + boundingBox +
"way[\"amenity\"~\"library\",i]" + boundingBox +
"node[\"amenity\"~\"restaurant\",i]" + boundingBox +
"way[\"amenity\"~\"restaurant\",i]" + boundingBox +
"node[\"shop\"~\"convenience\",i]" + boundingBox +
"way[\"shop\"~\"convenience\",i]" + boundingBox +
");out%20center;>;out%20skel%20qt;";
// Print the URI for debugging
Log.i("PointOfInterest", URI);
// Create queue for volley
mRequestQueue = Volley.newRequestQueue(context);
fetchJsonResponse(URI);
// Finish up by storing the list in a list and return it
List<List> poiMarkers = new ArrayList<>();
poiMarkers.add(markerZoom16);
poiMarkers.add(markerZoom18);
return poiMarkers;
}
示例14: getParkingLots
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
public List getParkingLots(Context context, MapView mapView){
mv = mapView;
mapContext = context;
String boundingBox = mapContext.getString(R.string.map_bounding_box);
String URI = "https://overpass-api.de/api/interpreter?" +
"data=[out:json][timeout:60];(" +
"way[\"name\"~\"Economy%20Lot\",i]" + boundingBox +
"relation[\"name\"~\"Economy%20Lot\",i]" + boundingBox +
"way[\"name\"~\"Student%20Parking\",i]" + boundingBox +
"relation[\"ref\"~\"Student%20Parking\",i]" + boundingBox +
"way[\"name\"~\"Faculty%20Parking\",i]" + boundingBox +
"relation[\"ref\"~\"Faculty%20Parking\",i]" + boundingBox +
"way[\"name\"~\"Visitor%20Parking\",i]" + boundingBox +
"relation[\"ref\"~\"Visitor%20Parking\",i]" + boundingBox +
"way[\"name\"~\"Garage\",i]" + boundingBox +
"relation[\"ref\"~\"Garage\",i]" + boundingBox +
");out%20center;>;out%20skel%20qt;";
mRequestQueue = Volley.newRequestQueue(context); // Create queue for volley
fetchJsonResponse(URI);
List<List> parking = new ArrayList<>();
parking.add(economyLots);
parking.add(facultyLots);
parking.add(garageLots);
parking.add(studentLots);
parking.add(visitorLots);
return parking;
}
示例15: onCreate
import com.mapbox.mapboxsdk.views.MapView; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_venue);
mMapView = (MapView) findViewById(R.id.mainMapView);
mMapView.onCreate(savedInstanceState);
mMapView.setAttributionVisibility(View.INVISIBLE);
mMapView.setLogoVisibility(View.INVISIBLE);
floorPicker = (Spinner)findViewById(R.id.floor_spinner);
searchTo = (AutoCompleteTextView)findViewById(R.id.searchto);
searchLayout = (LinearLayout)findViewById(R.id.search_layout);
searchFrom = (AutoCompleteTextView)findViewById(R.id.searchfrom);
searchButton = (ImageButton)findViewById(R.id.search);
routeButton = (ImageButton)findViewById(R.id.route);
locationButton = (ImageButton)findViewById(R.id.locate);
compassButton = (ImageButton)findViewById(R.id.compass);
extras = getIntent().getExtras();
if (extras != null) {
long venueid = extras.getLong("venueid");
api = ((DemoApplication)getApplicationContext()).getApi();
api.loadVenue(venueid, VenueActivity.this);
}
}