當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。