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


Java GeoJsonOptions类代码示例

本文整理汇总了Java中com.mapbox.mapboxsdk.style.sources.GeoJsonOptions的典型用法代码示例。如果您正苦于以下问题:Java GeoJsonOptions类的具体用法?Java GeoJsonOptions怎么用?Java GeoJsonOptions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GeoJsonOptions类属于com.mapbox.mapboxsdk.style.sources包,在下文中一共展示了GeoJsonOptions类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateMapSourceFromFeatureCollection

import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions; //导入依赖的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: addSource

import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions; //导入依赖的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

示例3: addClusteredGeoJsonSource

import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions; //导入依赖的package包/类
private void addClusteredGeoJsonSource() {

    // Add a new source from the GeoJSON data and set the 'cluster' option to true.
    try {
      mapboxMap.addSource(
        // Point to GeoJSON data. This example visualizes all M1.0+ earthquakes from
        // 12/22/15 to 1/21/16 as logged by USGS' Earthquake hazards program.
        new GeoJsonSource("earthquakes",
          new URL("https://www.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson"),
          new GeoJsonOptions()
            .withCluster(true)
            .withClusterMaxZoom(14)
            .withClusterRadius(50)
        )
      );
    } catch (MalformedURLException malformedUrlException) {
      Log.e("dataClusterActivity", "Check the URL " + malformedUrlException.getMessage());
    }


    // Use the earthquakes GeoJSON source to create three layers: One layer for each cluster category.
    // Each point range gets a different fill color.
    int[][] layers = new int[][] {
      new int[] {150, ContextCompat.getColor(this, R.color.mapboxRed)},
      new int[] {20, ContextCompat.getColor(this, R.color.mapboxGreen)},
      new int[] {0, ContextCompat.getColor(this, R.color.mapbox_blue)}
    };

    //Creating a marker layer for single data points
    SymbolLayer unclustered = new SymbolLayer("unclustered-points", "earthquakes");
    unclustered.setProperties(iconImage("marker-15"));
    mapboxMap.addLayer(unclustered);

    for (int i = 0; i < layers.length; i++) {
      //Add clusters' circles
      CircleLayer circles = new CircleLayer("cluster-" + i, "earthquakes");
      circles.setProperties(
        circleColor(layers[i][1]),
        circleRadius(18f)
      );

      // Add a filter to the cluster layer that hides the circles based on "point_count"
      circles.setFilter(
        i == 0
          ? gte("point_count", layers[i][0]) :
          all(gte("point_count", layers[i][0]), lt("point_count", layers[i - 1][0]))
      );
      mapboxMap.addLayer(circles);
    }

    //Add the count labels
    SymbolLayer count = new SymbolLayer("count", "earthquakes");
    count.setProperties(
      textField("{point_count}"),
      textSize(12f),
      textColor(Color.WHITE)
    );
    mapboxMap.addLayer(count);

  }
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:61,代码来源:GeoJsonClusteringActivity.java

示例4: addClusteredGeoJsonSource

import com.mapbox.mapboxsdk.style.sources.GeoJsonOptions; //导入依赖的package包/类
private void addClusteredGeoJsonSource(MapboxMap mapboxMap) {

    // Add a new source from our GeoJSON data and set the 'cluster' option to true.
    try {
      mapboxMap.addSource(
        // Point to GeoJSON data. This example visualizes all M1.0+ earthquakes from
        // 12/22/15 to 1/21/16 as logged by USGS' Earthquake hazards program.
        new GeoJsonSource("earthquakes",
          new URL("https://www.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson"),
          new GeoJsonOptions()
            .withCluster(true)
            .withClusterMaxZoom(15) // Max zoom to cluster points on
            .withClusterRadius(20) // Use small cluster radius for the hotspots look
        )
      );
    } catch (MalformedURLException malformedUrlException) {
      Log.e("CreateHotspotsActivity", "Check the URL " + malformedUrlException.getMessage());
    }

    // Use the earthquakes source to create four layers:
    // three for each cluster category, and one for unclustered points

    // Each point range gets a different fill color.
    final int[][] layers = new int[][]{
      new int[]{150, Color.parseColor("#E55E5E")},
      new int[]{20, Color.parseColor("#F9886C")},
      new int[]{0, Color.parseColor("#FBB03B")}
    };

    CircleLayer unclustered = new CircleLayer("unclustered-points", "earthquakes");
    unclustered.setProperties(
      circleColor(Color.parseColor("#FBB03B")),
      circleRadius(20f),
      circleBlur(1f));
    unclustered.setFilter(
      neq("cluster", true)
    );
    mapboxMap.addLayerBelow(unclustered, "building");

    for (int i = 0; i < layers.length; i++) {
      CircleLayer circles = new CircleLayer("cluster-" + i, "earthquakes");
      circles.setProperties(
        circleColor(layers[i][1]),
        circleRadius(70f),
        circleBlur(1f)
      );
      circles.setFilter(
        i == 0
          ? gte("point_count", layers[i][0]) :
          all(gte("point_count", layers[i][0]), lt("point_count", layers[i - 1][0]))
      );
      mapboxMap.addLayerBelow(circles, "building");
    }
  }
 
开发者ID:mapbox,项目名称:mapbox-android-demo,代码行数:55,代码来源:CreateHotspotsActivity.java


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