Hello folks, I have been working on Maps and facing issues with map labels.
I am working on WatchOS App SwiftUI, in there i have implemented Apple Maps. Since watch is small and there isn't much space to fit labels when user is fully zoomed in. i want to reduce some categories of unwanted labels. the solutions i have tried where leading me to results where there are All Labels or No Labels (except default labels like, street names and City Names)
for this i have physical devices:
Apple Watch Ultra with watchOS 10 beta (21R5320i), iPhone 14 pro max with iOS 17 beta 4 (21R5320i)
for this i have tried following ways
- i have used PointOfInterestCategories in iPhone first and it is working as expected with all categories and filter out defined categories. code i have used it as below.
Map(position: $position)
.mapStyle(.standard(pointsOfInterest: [
.hospital,
.hotel,
]))
- Then i have tried it in WatchOS Map like below code. For pointOfInterest i have to give rawValue because there are enums not available directly.
Map(position: $position, interactionModes: .all)
.mapStyle(
.standard(
pointsOfInterest: .excluding(
[
MKPointOfInterestCategory(
rawValue: "gasStation"
)
]
)
)
)
For giving rawValues i have also tried with different values like, MKPointOfInterestCategoryGasStation
from class "MKPointOfInterestCategory.h" as well as gasStation
directly
i know i have used different categories in Both examples but none of them are working.
form trying above solutions i am getting exact results from iPhone but in WatchOS it either providing me Map with all Labels or No Labels. i just want to hide some of them to be able to see the clear map details.
i think MKPointOfInterestCategory
is not returning the rawValue that's why pointOfInterest array is passing empty and not excluding the provided category.
If there are other ways to achieve this that i am not aware of it would be really helpful
Thank You :)