A symbol on Apple Maps, how can I show it in MapKit

The easiest way to explain this is to show it. On any device, open Maps, set it to Driving (which will show traffic). Go to Baltimore Maryland. In the water just south east of the city there is a bridge (Francis Scott Key Bridge). <the bridge was hit by a ship and the whole bridge fell into the water last year>. On Apple Maps the road is colored dark red.

At certain zoom levels, there is a "button" (red circle with a white - in it). When you click on that "button", it says 1 Advisory (Road Closed).

How do I show this "button" on my map. My map shows the dark red color, but no "button" appears.

The only "advisory" that I've been able to find is when you create a route. Of course you can't create a route over a road that fell into the water.

struct ContentView: View {
    
    @State private var position = MapCameraPosition.region(
        MKCoordinateRegion(
            center: CLLocationCoordinate2D(latitude: 39.22742855118304, longitude: -76.52228412310761),
            span: MKCoordinateSpan(latitudeDelta: 0.05407607689684113, longitudeDelta: 0.04606660133347873)
        )
    )
    
    var body: some View {
        Map(position: $position)
            .mapStyle(.standard(pointsOfInterest: .all, showsTraffic: true))
            .cornerRadius(25)
    }
}

Is this a WCDWAD, or is there a way to show the "button" (We Can't Do What Apple Does)

Answered by DTS Engineer in 825978022

I take it from your description that you're looking for the showsTraffic configuration to include all annotation and incident details, as found in the Apple Maps app. There isn't an API that will provide your app with live traffic incident annotations, but if you'd like us to consider adding such an API in the future, please open an enhancement request, and let us know what you'd like to do and what use cases you have in mind.

— Ed Ford,  DTS Engineer

Isn't that just an annotation?

Don't use the "comments" feature. It's too easy to not notice them.

You can add annotations whenever you want. If you are looking at a region where you have an annotation and you are at a scale where you want to display it, then display it. You get callbacks whenever you change the visible rect.

In the example I used in the question, the bridge will be closed for a very long time. I used this as I knew that the road closed symbol would be there for some time, so anyone that might be able to answer the question would see what I'm talking about.

But in the real world, roads get closed on a daily basis, then reopened (accidents, construction, etc). Apple Maps appears to show the road closed symbol automatically, yet when I use the code above, it doesn't show the symbol, just the live reporting that changes the color to that dark red. I'd like my project to show these road closed symbols as well... if I could figure out what they are called.

Accepted Answer

I take it from your description that you're looking for the showsTraffic configuration to include all annotation and incident details, as found in the Apple Maps app. There isn't an API that will provide your app with live traffic incident annotations, but if you'd like us to consider adding such an API in the future, please open an enhancement request, and let us know what you'd like to do and what use cases you have in mind.

— Ed Ford,  DTS Engineer

Apple Maps appears to show the road closed symbol automatically, yet when I use the code above, it doesn't show the symbol, just the live reporting that changes the color to that dark red. I'd like my project to show these road closed symbols as well... if I could figure out what they are called.

They're called Annotations.

But the important part here is that Apple Maps is not MapKit. You actually don't get the live reporting of road conditions. What you get is a base layer that just happens to be updated in response to those conditions.

You could look for a 3rd party service. Just be sure to carefully review the terms and conditions to ensure you could use it with MapKit. Some services can only be used with mapping services from the save provider.

If you are only interested in a small area, then you might be able to pull data directly from a local or regional government traffic ministry.

A symbol on Apple Maps, how can I show it in MapKit
 
 
Q