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


Java FeatureCollection.fromFeatures方法代码示例

本文整理汇总了Java中com.mapbox.services.commons.geojson.FeatureCollection.fromFeatures方法的典型用法代码示例。如果您正苦于以下问题:Java FeatureCollection.fromFeatures方法的具体用法?Java FeatureCollection.fromFeatures怎么用?Java FeatureCollection.fromFeatures使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mapbox.services.commons.geojson.FeatureCollection的用法示例。


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

示例1: updateMapSourceFromFeatureCollection

import com.mapbox.services.commons.geojson.FeatureCollection; //导入方法依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:26,代码来源:MapUtils.java

示例2: waypointFeatureCollection

import com.mapbox.services.commons.geojson.FeatureCollection; //导入方法依赖的package包/类
/**
 * The routes also display an icon for each waypoint in the route, we use symbol layers for this.
 */
private static FeatureCollection waypointFeatureCollection(DirectionsRoute route) {
  final List<Feature> waypointFeatures = new ArrayList<>();
  for (RouteLeg leg : route.legs()) {
    waypointFeatures.add(getPointFromLineString(leg, 0));
    waypointFeatures.add(getPointFromLineString(leg, leg.steps().size() - 1));
  }
  return FeatureCollection.fromFeatures(waypointFeatures);
}
 
开发者ID:mapbox,项目名称:mapbox-navigation-android,代码行数:12,代码来源:NavigationMapRoute.java

示例3: addSource

import com.mapbox.services.commons.geojson.FeatureCollection; //导入方法依赖的package包/类
private void addSource(String sourceId) {
  FeatureCollection emptyFeature = FeatureCollection.fromFeatures(new Feature[] {});
  GeoJsonSource locationSource = new GeoJsonSource(
    sourceId,
    emptyFeature,
    new GeoJsonOptions().withMaxZoom(16));
  mapboxMap.addSource(locationSource);
  sourceMap.put(sourceId, locationSource);
}
 
开发者ID:mapbox,项目名称:mapbox-plugins-android,代码行数:10,代码来源:LocationLayer.java

示例4: onMapClick

import com.mapbox.services.commons.geojson.FeatureCollection; //导入方法依赖的package包/类
@Override
public void onMapClick(@NonNull LatLng point) {

  final SymbolLayer marker = (SymbolLayer) mapboxMap.getLayer("selected-marker-layer");

  final PointF pixel = mapboxMap.getProjection().toScreenLocation(point);
  List<Feature> features = mapboxMap.queryRenderedFeatures(pixel, "marker-layer");
  List<Feature> selectedFeature = mapboxMap.queryRenderedFeatures(pixel, "selected-marker-layer");

  if (selectedFeature.size() > 0 && markerSelected) {
    return;
  }

  if (features.isEmpty()) {
    if (markerSelected) {
      deselectMarker(marker);
    }
    return;
  }

  FeatureCollection featureCollection = FeatureCollection.fromFeatures(
    new Feature[]{Feature.fromGeometry(features.get(0).getGeometry())});
  GeoJsonSource source = mapboxMap.getSourceAs("selected-marker");
  if (source != null) {
    source.setGeoJson(featureCollection);
  }

  if (markerSelected) {
    deselectMarker(marker);
  }
  if (features.size() > 0) {
    selectMarker(marker);
  }
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:35,代码来源:BasicSymbolLayerActivity.java

示例5: onMapReady

import com.mapbox.services.commons.geojson.FeatureCollection; //导入方法依赖的package包/类
@Override
public void onMapReady(MapboxMap mapboxMap) {

  this.mapboxMap = mapboxMap;

  List<Feature> markerCoordinates = new ArrayList<>();
  markerCoordinates.add(Feature.fromGeometry(
    Point.fromCoordinates(Position.fromCoordinates(-71.065634, 42.354950))) // Boston Common Park
  );
  markerCoordinates.add(Feature.fromGeometry(
    Point.fromCoordinates(Position.fromCoordinates(-71.097293, 42.346645))) // Fenway Park
  );
  markerCoordinates.add(Feature.fromGeometry(
    Point.fromCoordinates(Position.fromCoordinates(-71.053694, 42.363725))) // The Paul Revere House
  );
  FeatureCollection featureCollection = FeatureCollection.fromFeatures(markerCoordinates);

  Source geoJsonSource = new GeoJsonSource("marker-source", featureCollection);
  mapboxMap.addSource(geoJsonSource);

  Bitmap icon = BitmapFactory.decodeResource(
    BasicSymbolLayerActivity.this.getResources(), R.drawable.blue_marker_view);

  // Add the marker image to map
  mapboxMap.addImage("my-marker-image", icon);

  SymbolLayer markers = new SymbolLayer("marker-layer", "marker-source")
    .withProperties(PropertyFactory.iconImage("my-marker-image"));
  mapboxMap.addLayer(markers);

  // Add the selected marker source and layer
  FeatureCollection emptySource = FeatureCollection.fromFeatures(new Feature[]{});
  Source selectedMarkerSource = new GeoJsonSource("selected-marker", emptySource);
  mapboxMap.addSource(selectedMarkerSource);

  SymbolLayer selectedMarker = new SymbolLayer("selected-marker-layer", "selected-marker")
    .withProperties(PropertyFactory.iconImage("my-marker-image"));
  mapboxMap.addLayer(selectedMarker);

  mapboxMap.addOnMapClickListener(this);
}
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:42,代码来源:BasicSymbolLayerActivity.java


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