Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Improved CustomGeometrySource constructor typing #13200

Merged
merged 1 commit into from
Nov 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public CustomGeometrySource(String id, GeometryTileProvider provider) {
}

/**
* Create a CustomGeometrySource with non-default CustomGeometrySourceOptions.
* <p>Supported options are minZoom, maxZoom, buffer, and tolerance.</p>
* @param id The source id.
* Create a CustomGeometrySource with non-default {@link CustomGeometrySourceOptions}.
*
* @param id The source id.
* @param options CustomGeometrySourceOptions.
* @param provider The tile provider that returns geometry data for this source.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.mapbox.mapboxsdk.style.sources;

import java.util.HashMap;

/**
* Builder class for composing CustomGeometrySource objects.
*/
public class CustomGeometrySourceOptions extends GeoJsonOptions {
public class CustomGeometrySourceOptions extends HashMap<String, Object> {

/**
* If the data includes wrapped coordinates, setting this to true unwraps the coordinates.
Expand All @@ -28,4 +30,48 @@ public CustomGeometrySourceOptions withClip(boolean clip) {
return this;
}

/**
* Minimum zoom level at which to create vector tiles (lower means more field of view detail at low zoom levels).
*
* @param minZoom the minimum zoom - Defaults to 0.
* @return the current instance for chaining
*/
public CustomGeometrySourceOptions withMinZoom(int minZoom) {
this.put("minzoom", minZoom);
return this;
}

/**
* Maximum zoom level at which to create vector tiles (higher means greater detail at high zoom levels).
*
* @param maxZoom the maximum zoom - Defaults to 25.5
* @return the current instance for chaining
*/
public CustomGeometrySourceOptions withMaxZoom(int maxZoom) {
this.put("maxzoom", maxZoom);
return this;
}

/**
* Tile buffer size on each side (measured in 1/512ths of a tile; higher means fewer rendering artifacts near tile
* edges but slower performance).
*
* @param buffer the buffer size - Defaults to 128.
* @return the current instance for chaining
*/
public CustomGeometrySourceOptions withBuffer(int buffer) {
this.put("buffer", buffer);
return this;
}

/**
* Douglas-Peucker simplification tolerance (higher means simpler geometries and faster performance).
*
* @param tolerance the tolerance - Defaults to 0.375
* @return the current instance for chaining
*/
public CustomGeometrySourceOptions withTolerance(float tolerance) {
this.put("tolerance", tolerance);
return this;
}
}