Java Code Examples for com.mapbox.mapboxsdk.style.sources.GeoJsonSource#setGeoJson()
The following examples show how to use
com.mapbox.mapboxsdk.style.sources.GeoJsonSource#setGeoJson() .
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: MapUtils.java From graphhopper-navigation-android with MIT License | 6 votes |
/** * 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); } }
Example 2
Source File: CircleContainer.java From AirMapSDK-Android with Apache License 2.0 | 6 votes |
public void move(LatLng center) { this.center = center; this.points = calculateCirclePoints(center, radius); List<Point> positions = latLngsToPositions(points); List<List<Point>> coordinates = new ArrayList<>(); coordinates.add(positions); List<Point> lineString = new ArrayList<>(positions); lineString.add(positions.get(0)); GeoJsonSource pointSource = map.getStyle().getSourceAs(POINT_SOURCE); pointSource.setGeoJson(Feature.fromGeometry(Point.fromLngLat(center.getLongitude(), center.getLatitude()))); GeoJsonSource polygonSource = map.getStyle().getSourceAs(POLYGON_SOURCE); polygonSource.setGeoJson(Feature.fromGeometry(Polygon.fromLngLats(coordinates))); FillLayer polygonFill = map.getStyle().getLayerAs(Container.POLYGON_LAYER); polygonFill.setProperties(PropertyFactory.fillColor(ContextCompat.getColor(context, R.color.colorAccent))); GeoJsonSource polylineSource = map.getStyle().getSourceAs(POLYLINE_SOURCE); polylineSource.setGeoJson(Feature.fromGeometry(LineString.fromLngLats(lineString))); }
Example 3
Source File: PolygonContainer.java From AirMapSDK-Android with Apache License 2.0 | 6 votes |
public boolean checkForIntersections() { List<LatLng> points = PointMath.findIntersections(path); if (points.isEmpty()) { return false; } List<Point> intersections = latLngsToPositions(points); if (map.getStyle().getLayer(INTERSECTION_LAYER) == null) { Source intersectionSource = new GeoJsonSource(INTERSECTION_SOURCE, Feature.fromGeometry(MultiPoint.fromLngLats(intersections))); map.getStyle().addSource(intersectionSource); Layer intersectionLayer = new SymbolLayer(INTERSECTION_LAYER, INTERSECTION_SOURCE) .withProperties(PropertyFactory.iconImage(INTERSECTION_IMAGE)); map.getStyle().addLayer(intersectionLayer); } else { GeoJsonSource intersectionsSource = map.getStyle().getSourceAs(INTERSECTION_SOURCE); intersectionsSource.setGeoJson(Feature.fromGeometry(MultiPoint.fromLngLats(intersections))); } return true; }
Example 4
Source File: MapDataManager.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
public void refreshSource(int contactId) { MapSource source = contactMapSources.get(contactId); LinkedList<Feature> collection = featureCollections.get(source.getMarkerFeatureCollection()); GeoJsonSource pointSource = (GeoJsonSource) mapboxStyle.getSource(source.getMarkerSource()); pointSource.setGeoJson(FeatureCollection.fromFeatures(collection)); LinkedList<Feature> lineFeatures = featureCollections.get(source.getLineFeatureCollection()); GeoJsonSource lineSource = (GeoJsonSource) mapboxStyle.getSource(source.getLineSource()); lineSource.setGeoJson(FeatureCollection.fromFeatures(lineFeatures)); GeoJsonSource lastPostionSource = (GeoJsonSource) mapboxStyle.getSource(LAST_POSITION_SOURCE); lastPostionSource.setGeoJson(FeatureCollection.fromFeatures(new LinkedList<>(lastPositions.values()))); }
Example 5
Source File: MapDataManager.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
public boolean unselectMarker() { if (selectedFeature != null) { selectedFeature.addBooleanProperty(MARKER_SELECTED, false); refreshSource(selectedFeature.getNumberProperty(CONTACT_ID).intValue()); selectedFeature = null; GeoJsonSource source = (GeoJsonSource) mapboxStyle.getSource(INFO_WINDOW_SRC); source.setGeoJson(FeatureCollection.fromFeatures(new ArrayList<>())); return true; } return false; }
Example 6
Source File: MapDataManager.java From deltachat-android with GNU General Public License v3.0 | 5 votes |
/** * Invoked when the bitmaps have been generated from a view. */ @Override public void setInfoWindowResults(Bitmap result) { mapboxStyle.addImage(INFO_WINDOW_ID, result); GeoJsonSource infoWindowSource = (GeoJsonSource) mapboxStyle.getSource(INFO_WINDOW_SRC); infoWindowSource.setGeoJson(selectedFeature); }