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

Add feature id to annotations; prepare showcase of callout annotations #994

Merged
merged 4 commits into from
Dec 15, 2021

Conversation

kiryldz
Copy link
Contributor

@kiryldz kiryldz commented Dec 14, 2021

Summary of changes

Expose unique feature identifier for all annotations created by annotation plugin. This feature id is used when preparing a Feature that backs up annotation. This feature id could now be used to connect annotation with view annotation.

Prepare an example of annotation usage (drawing a marker) and associated view annotation.

device-2021-12-15-093611.mp4

User impact (optional)

Pull request checklist:

  • Briefly describe the changes in this PR.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality. If tests were not written, please explain why.
  • Optimize code for java consumption (@JvmOverloads, @file:JvmName, etc).
  • Add example if relevant.
  • Document any changes to public APIs.
  • Apply changelog label ('breaking change', 'bug 🪲', 'build', 'docs', 'feature 🍏', 'performance ⚡', 'testing 💯') or use the label 'skip changelog'
  • Add an entry inside this element for inclusion in the mapbox-maps-android changelog: <changelog>Expose unique annotation feature identifier that could be used to link view annotation to any annotation.</changelog>.
  • If this PR is a v10.[version] release branch fix / enhancement, merge it to main firstly and then port to v10.[version] release branch.

Fixes: < Link to related issues that will be fixed by this pull request, if they exist >

PRs must be submitted under the terms of our Contributor License Agreement CLA.

@kiryldz kiryldz requested a review from a team December 14, 2021 14:27
@kiryldz kiryldz self-assigned this Dec 14, 2021
@kiryldz kiryldz marked this pull request as ready for review December 14, 2021 16:04
@macdrevx
Copy link
Contributor

macdrevx commented Dec 14, 2021

The iOS SDK has used the annotation id as the feature ID since v10.0.0: https://github.com/mapbox/mapbox-maps-ios/blob/v10.0.0/Sources/MapboxMaps/Annotations/Generated/PointAnnotation.swift#L25

It defaults the IDs to a UUID string, but developers can provide any string they like: https://github.com/mapbox/mapbox-maps-ios/blob/main/Sources/MapboxMaps/Annotations/Generated/PointAnnotation.swift#L45

Some alignment questions:

  • Is it necessary to prefix the ID? If not, we could be aligned without any changes to iOS.
  • If we choose not to prefix, could we eliminate the new featureIdentifier property and just document that id is used as the underlying feature ID?

Overall, I like the concept.

@kiryldz
Copy link
Contributor Author

kiryldz commented Dec 14, 2021

The iOS SDK has used the annotation id as the feature ID since v10.0.0: https://github.com/mapbox/mapbox-maps-ios/blob/v10.0.0/Sources/MapboxMaps/Annotations/Generated/PointAnnotation.swift#L25

It defaults the IDs to a UUID string, but developers can provide any string they like: https://github.com/mapbox/mapbox-maps-ios/blob/main/Sources/MapboxMaps/Annotations/Generated/PointAnnotation.swift#L45

Some alignment questions:

  • Is it necessary to prefix the ID? If not, we could be aligned without any changes to iOS.
  • If we choose not to prefix, could we eliminate the new featureIdentifier property and just document that id is used as the underlying feature ID?

Overall, I like the concept.

@macdrevx thanks for looking into it!
I was also thinking of actually using our Annotation.id exposed already but my main concern here is that we generate it not as UUID but simply as 0, 1, 2 etc. which (at least for me) looks a bit unreliable to use such an easy id when preparing a Feature (using static method Feature.fromGeometry(geometry, properties, id)).

At the same time we can't re-use Annotation.id making generating UUID more complex from our end as it is Long and not String. That's actually why current solution is used: concat unique prefix + incremental annotation id we generate.

To sum up, at least from my understanding, perhaps there's no need to even add anything on iOS then. It would be nice to prepare similar example to show users how to use point annotation with an icon with view annotation but no need to align on Annotation.featureIdentifier as it seems we're not perfectly aligned anyway (e.g. our id is Long, there's no way to allow user provide their own feature id as we don't even assign feature an id before this PR).

@macdrevx
Copy link
Contributor

Sounds good to me. Could you open a ticket for iOS to add the example? cc: @endanke is that something you could do?

@endanke
Copy link

endanke commented Dec 15, 2021

@macdrevx @kiryldz sure! I'll open a ticket and assign myself. Although I don't think I can work on it before my holidays, but I'll pick it up in January.

@kiryldz kiryldz merged commit fe87eab into main Dec 15, 2021
@kiryldz kiryldz deleted the kdz-annotation-with-view-annotation branch December 15, 2021 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants