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

Draggable marker example #12326

Merged
merged 2 commits into from Jul 6, 2018
Merged

Draggable marker example #12326

merged 2 commits into from Jul 6, 2018

Conversation

LukasPaczos
Copy link
Member

Refs #2450.
Adds an example of how to build a class that is responsible for handling dragged symbols and disptaching callbacks with the drag state.

Also, adds Kotlin dependencies to the test app.

ezgif com-video-to-gif 2

@LukasPaczos LukasPaczos added the Android Mapbox Maps SDK for Android label Jul 5, 2018
@LukasPaczos LukasPaczos added this to the android-v6.3.0 milestone Jul 5, 2018
@LukasPaczos LukasPaczos requested a review from tobrun July 5, 2018 18:47
@LukasPaczos LukasPaczos force-pushed the lp-draggable-marker-activity branch from 858a11c to 03a9fa3 Compare July 5, 2018 18:50
@@ -82,3 +83,6 @@ apply from: "${rootDir}/gradle/gradle-checkstyle.gradle"
apply from: "${rootDir}/gradle/gradle-lint.gradle"



apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

val point = featureCollection.features()?.find {
it.id() == id
}?.geometry() as Point
draggedMarkerPositionTv.text = String.format("Dragged marker's position: %.4f, %.4f", point.latitude(), point.longitude())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a more kotlin friendly way to do string formatting?


private fun MapboxMap.queryRenderedSymbols(latLng: LatLng, layerId: String): List<Feature> {
return this.queryRenderedFeatures(this.projection.toScreenLocation(latLng), layerId)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Loving these extension functions!

@tobrun tobrun mentioned this pull request Jul 6, 2018
@LukasPaczos LukasPaczos force-pushed the lp-draggable-marker-activity branch from 03a9fa3 to d580765 Compare July 6, 2018 09:58
@LukasPaczos LukasPaczos merged commit 282f89a into master Jul 6, 2018
@LukasPaczos LukasPaczos deleted the lp-draggable-marker-activity branch July 6, 2018 11:22
@iamanvesh
Copy link

I have tried to use DraggableSymbolsManager with my app but there's an issue if we use a style which has some layers already present in it. It was throwing a segmentation fault error if we try to use style with SymbolLayer simultaneously.

// Setting up markers icon, source and layer
mapboxMap.addImage(markerImageId, IconFactory.getInstance(this).defaultMarker().bitmap)
mapboxMap.addSource(source)
mapboxMap.addLayer(layer)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steps to replicate the issue.

  • Use the API key which has a predefined style with some custom layers created using mapbox studio.

  • Apply the style using setStyleUrl()

  • Try to add this layer in onStyleLoaded() callback.

It was throwing a segmentation fault error when I tried this.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue was caused because I was trying to add the source before the style has loaded. I tried adding source and layer both in onStyleLoaded callback and its working.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm glad to hear that @iamanvesh! Let us know if you run into any other issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Android Mapbox Maps SDK for Android
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants