Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Annotation plugin] Add GeoJsonOptions to allow to configure the underlying used GeoJsonSource #79

Merged
merged 2 commits into from
Feb 22, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -156,6 +156,15 @@ abstract class Layer : StyleContract.StyleLayerExtension {
throw RuntimeException("Couldn't get $propertyName: layer is not added to style yet.")
}

/**
* Returns a human readable string that includes the cached properties of the layer.
*
* @return String
*/
override fun toString(): String {
return "[${layerProperties.values.joinToString { propertyValue -> "${propertyValue.propertyName} = ${propertyValue.value}" }}}]"
}

/**
* Static variables and methods.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.mapbox.maps.extension.style.layers.addLayerBelow
import com.mapbox.maps.extension.style.layers.properties.PropertyValue
import com.mapbox.maps.extension.style.sources.addSource
import com.mapbox.maps.extension.style.sources.generated.GeoJsonSource
import com.mapbox.maps.extension.style.sources.generated.geoJsonSource
import com.mapbox.maps.plugin.InvalidPluginConfigurationException
import com.mapbox.maps.plugin.PLUGIN_GESTURE_CLASS_NAME
import com.mapbox.maps.plugin.annotation.generated.Symbol
Expand All @@ -41,7 +42,7 @@ abstract class AnnotationManagerImpl<G : Geometry, T : Annotation<G>, S : Annota
mapView: View,
/** The delegateProvider */
final override val delegateProvider: MapDelegateProvider,
private val annotationConfig: AnnotationConfig?
protected val annotationConfig: AnnotationConfig?
) : AnnotationManager<G, T, S, D, U, V> {
protected lateinit var style: StyleManagerInterface
private var mapProjectionDelegate: MapProjectionDelegate = delegateProvider.mapProjectionDelegate
Expand All @@ -59,7 +60,8 @@ abstract class AnnotationManagerImpl<G : Geometry, T : Annotation<G>, S : Annota
private var draggedAnnotation: T? = null
protected var touchAreaShiftX: Int = mapView.scrollX
protected var touchAreaShiftY: Int = mapView.scrollY

protected abstract val layerId: String
protected abstract val sourceId: String
private var gesturesPlugin: GesturesPlugin = delegateProvider.mapPluginProviderDelegate.getPlugin(
Class.forName(
PLUGIN_GESTURE_CLASS_NAME
Expand Down Expand Up @@ -115,13 +117,6 @@ abstract class AnnotationManagerImpl<G : Geometry, T : Annotation<G>, S : Annota
*/
abstract fun getAnnotationIdKey(): String

/**
* Create the source for managed annotations
*
* @return the GeoJsonSource created
*/
protected abstract fun createSource(): GeoJsonSource

/**
* Create the layer for managed annotations
*
Expand All @@ -134,6 +129,32 @@ abstract class AnnotationManagerImpl<G : Geometry, T : Annotation<G>, S : Annota
*/
abstract var layerFilter: Expression?

private fun createSource(): GeoJsonSource {
return geoJsonSource(sourceId) {
data("")
annotationConfig?.geoJsonOptions?.let { options ->
options.buffer?.let {
buffer(it)
}
options.cluster?.let {
cluster(it)
}
options.clusterMaxZoom?.let {
clusterMaxZoom(it)
}
options.lineMetrics?.let {
lineMetrics(it)
}
options.tolerance?.let {
tolerance(it)
}
options.clusterProperties?.let {
clusterProperties(it)
}
}
}
}

protected fun initLayerAndSource() {
if (layer == null || source == null) {
initializeDataDrivenPropertyMap()
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading