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

Allow option to set SDF on a PointAnnotation image modifier using SwiftUI #2295

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

AppleJuiceBreak
Copy link

@AppleJuiceBreak AppleJuiceBreak commented Feb 24, 2025

As far as I can tell when using SwiftUI with a PointAnnotation and the image(named: String) modifier there doesn't seem to be a way to enable SDF, not without tapping into MapViewReader.

If doing:

Map(viewport: $viewport) {
    PointAnnotationGroup(annotations, id: \.id) { annotation in
        PointAnnotation(coordinate: annotation.coordinates)
            .image(named: "marker-icon")
            .iconColor(.red)
    }
}

The icon color would of course not be red as SDF was not enabled. In this PR i've optionally added the ability to set SDF directly on the modifier

Map(viewport: $viewport) {
    PointAnnotationGroup(annotations, id: \.id) { annotation in
        PointAnnotation(coordinate: annotation.coordinates)
            .image(named: "marker-icon", sdf: true) // as long as the image is SDF enabled, the icon should now be red
            .iconColor(.red)
    }
}

Pull request checklist:

  • Describe the changes in this PR, especially public API changes.
  • Include before/after visuals or gifs if this PR includes visual changes.
  • Write tests for all new functionality. Put tests in correct Test Plan (Unit, Integration, All)
    • If tests were not written, please explain why.
  • Add documentation comments for any added or updated public APIs.
  • Add any new public, top-level symbols to the DocC custom catatlog (Sources/MapboxMaps/Documentation.docc/API Catalogs)
  • Add a changelog entry to to bottom of the relevant section (typically the ## main heading near the top).
  • Update the guides (internal access only), README.md, and DEVELOPING.md if their contents are impacted by these changes.
  • If this PR is a v10.[version] release branch fix / enhancement, merge it to main first and then port to v10.[version] release branch.

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

@AppleJuiceBreak AppleJuiceBreak requested a review from a team as a code owner February 24, 2025 14:05
@CLAassistant
Copy link

CLAassistant commented Feb 24, 2025

CLA assistant check
All committers have signed the CLA.

@AppleJuiceBreak AppleJuiceBreak changed the title Allow option to set SDF on a PointAnnotation image modifier using Swi… Allow option to set SDF on a PointAnnotation image modifier using SwiftUI Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants