Java Code Examples for com.mapbox.mapboxsdk.geometry.LatLngBounds#Builder
The following examples show how to use
com.mapbox.mapboxsdk.geometry.LatLngBounds#Builder .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataCollectionTask.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
public DataCollectionTask(DcContext context, int chatId, int[] contactIds, ConcurrentHashMap<Integer, MapSource> contactMapSources, ConcurrentHashMap featureCollections, ConcurrentHashMap<Integer, Feature> lastPositions, LatLngBounds.Builder boundingBuilder, DataCollectionCallback callback) { this.chatId = chatId; this.contactMapSources = contactMapSources; this.featureCollections = featureCollections; this.lastPositions = lastPositions; this.boundingBuilder = boundingBuilder; this.dcContext = context; this.callback = callback; this.contactIds = contactIds; instances.add(this); }
Example 2
Source File: MapDataManager.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
public MapDataManager(Context context, @NonNull Style mapboxMapStyle, LocationComponent locationComponent, int chatId, MapDataState updateCallback) { Log.d(TAG, "performance test - create map manager"); this.mapboxStyle = mapboxMapStyle; this.context = context; this.dcContext = DcHelper.getContext(context); this.chatId = chatId; boundingBuilder = new LatLngBounds.Builder(); this.callback = updateCallback; this.locationComponent = locationComponent; initInfoWindowLayer(); initLastPositionLayer(); initLocationComponent(); filterProvider.setMessageFilter(true); filterProvider.setLastPositionFilter(System.currentTimeMillis() - DEFAULT_LAST_POSITION_DELTA); applyLastPositionFilter(); updateSources(); dcContext.eventCenter.addObserver(DC_EVENT_LOCATION_CHANGED, this); Log.d(TAG, "performance test - create map manager finished"); }
Example 3
Source File: LineContainer.java From AirMapSDK-Android with Apache License 2.0 | 5 votes |
@Override public LatLngBounds getLatLngBoundsForZoom() { LatLngBounds.Builder latLngBounds = new LatLngBounds.Builder(); for (List<Point> list : polygon.coordinates()) { for (Point position : list) { latLngBounds.include(new LatLng(position.latitude(), position.longitude())); } } return latLngBounds.build(); }
Example 4
Source File: PolygonContainer.java From AirMapSDK-Android with Apache License 2.0 | 5 votes |
@Override public LatLngBounds getLatLngBoundsForZoom() { LatLngBounds.Builder latLngBounds = new LatLngBounds.Builder(); for (List<Point> list : polygon.coordinates()) { for (Point position : list) { latLngBounds.include(new LatLng(position.latitude(), position.longitude())); } } return latLngBounds.build(); }
Example 5
Source File: AirMapMapView.java From AirMapSDK-Android with Apache License 2.0 | 5 votes |
private void zoomToFeatureIfNecessary(Feature featureClicked) { LatLngBounds cameraBounds = getMap().getProjection().getVisibleRegion().latLngBounds; LatLngBounds.Builder advisoryLatLngsBuilder = new LatLngBounds.Builder(); boolean zoom = false; Geometry geometry = featureClicked.geometry(); List<Point> points = new ArrayList<>(); if (geometry instanceof Polygon) { points.addAll(((Polygon) geometry).outer().coordinates()); } else if (geometry instanceof MultiPolygon) { List<Polygon> polygons = ((MultiPolygon) geometry).polygons(); for (Polygon polygon : polygons) { points.addAll(polygon.outer().coordinates()); } } for (Point position : points) { LatLng latLng = new LatLng(position.latitude(), position.longitude()); advisoryLatLngsBuilder.include(latLng); if (!cameraBounds.contains(latLng)) { Timber.d("Camera position doesn't contain point"); zoom = true; } } if (zoom) { int padding = Utils.dpToPixels(getContext(), 72).intValue(); getMap().moveCamera(CameraUpdateFactory.newLatLngBounds(advisoryLatLngsBuilder.build(), padding)); } }
Example 6
Source File: DataCollector.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
public DataCollector(DcContext dcContext, ConcurrentHashMap<Integer, MapSource> contactMapSources, ConcurrentHashMap<String, LinkedList<Feature>> featureCollections, ConcurrentHashMap<Integer, Feature> lastPositions, LatLngBounds.Builder boundingBuilder) { this.dcContext = dcContext; this.contactMapSources = contactMapSources; this.featureCollections = featureCollections; this.lastPositions = lastPositions; this.boundingBuilder = boundingBuilder; }
Example 7
Source File: NavigationLauncherActivity.java From graphhopper-navigation-example with Apache License 2.0 | 4 votes |
@Override public void onPostExecuteGeocodingSearch(List<GeocodingLocation> locations) { clearGeocodingResults(); markers = new ArrayList<>(locations.size()); if (locations.isEmpty()) { onError(R.string.error_geocoding_no_location); return; } List<LatLng> bounds = new ArrayList<>(); Location lastKnownLocation = getLastKnownLocation(); if (lastKnownLocation != null) bounds.add(new LatLng(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude())); for (GeocodingLocation location : locations) { GeocodingPoint point = location.getPoint(); MarkerOptions markerOptions = new MarkerOptions(); LatLng latLng = new LatLng(point.getLat(), point.getLng()); markerOptions.position(latLng); bounds.add(latLng); markerOptions.title(location.getName()); String snippet = ""; if (location.getStreet() != null) { snippet += location.getStreet(); if (location.getHousenumber() != null) snippet += " " + location.getHousenumber(); snippet += "\n"; } if (location.getCity() != null) { if (location.getPostcode() != null) snippet += location.getPostcode() + " "; snippet += location.getCity() + "\n"; } if (location.getCountry() != null) snippet += location.getCountry() + "\n"; if (location.getOsmId() != null) { snippet += "OSM-Id: " + location.getOsmId() + "\n"; if (location.getOsmKey() != null) snippet += "OSM-Key: " + location.getOsmKey() + "\n"; if (location.getOsmType() != null) snippet += "OSM-Type: " + location.getOsmType() + "\n"; } snippet += "\n\n Tap on info window\n to add point to route"; if (!snippet.isEmpty()) markerOptions.snippet(snippet); markerOptions.icon(IconFactory.getInstance(this.getApplicationContext()).fromResource(R.drawable.ic_map_marker)); markers.add(mapboxMap.addMarker(markerOptions)); } // For bounds we need at least 2 entries if (bounds.size() >= 2) { LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder(); boundsBuilder.includes(bounds); animateCameraBbox(boundsBuilder.build(), CAMERA_ANIMATION_DURATION, padding); } else if (bounds.size() == 1) { // If there is only 1 result (=>current location unknown), we just zoom to that result animateCamera(bounds.get(0)); } hideLoading(); }