Apple Maps Server API

RSS for tag

Increase performance, lower data usage, and improve battery life across platforms for a variety of Apple Maps features.

Posts under Apple Maps Server API tag

15 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

How the duck can I use .p8 to get the Mapkit Server API token to use it without 7 day duration?
https://developer.apple.com/documentation/applemapsserverapi/creating-and-using-tokens-with-maps-server-api This doesn't really say what to do with .p8 private key. I know I am a noob but I really don't understand Apple Doc at all. There is no example or anything like that. const appleMapKit = await fetch("https://maps-api.apple.com/v1/token", { headers: { Authorization: `Bearer ${server_api_token}`, }, }); This is what I did but because I created the token on website, server_api_token only lasts 7 days. So, I tried to use Profile - Key to replace that. I have .p8 file and how can I use this to create the token for the server api?
1
0
102
1w
Apple Maps Server API Unauthorized Error
I'm trying to use the new Apple Maps Server API. As far as I can tell I have set up the token correctly, but my web request is still returning 401 unauthorized. The following is my code in TypeScript: import * as jwt from 'jsonwebtoken'; const JWT_SECRET = "-----BEGIN PRIVATE KEY-----\n" + "MIGTAgEAMBMGBy..............................\n" + "..............................................................\n" + "..............................................................\n" + "-----END PRIVATE KEY-----"; const header = { alg: "ES256", kid: "26DYPK65ZK", typ: "jwt" } // Example payload data const payload = { "iss": "7F3PBYWYMS", "iat": Date.now(), "exp": Date.now() + (1000 * 30 * 60), }; export async function getRestaurants() { let token = jwt.sign(payload, JWT_SECRET, { algorithm: 'ES256', header: header}); const response = await fetch('https://maps-api.apple.com/v1/token (https://maps-api.apple.com/v1/token)', { method: 'GET', headers: { 'Authorization': "Bearer " + token }, }); console.log(response); } What am I doing incorrectly here?
6
0
200
1w
Did the Snapshot API authentication change too?
Previously (and still, according to the documentation) building a Map Snapshot URL required building the URL with all its parameters, and then signing it using your private key. However, the URL created via the "Create a map" tool simply appends the pre-generated token on the end of the URL. And if I build a URL and do the same thing - append the token, but do not create a signature - the snapshot is generated correctly. (Omitting the token leads to a "not authenticated" message). Is this a new, easier way to generate snapshots?
1
1
476
Jun ’24
Multi Polygons MapKit
Is MultiPolygon overlay support going to be integrated with SwiftUI? I have made a post on here previously without a reply :( Any suggestions on how to display multi-polygons within MapKit for SwiftUI(https://developer.apple.com/documentation/mapkit/mappolygon)? At the moment it is not supported and only supported by MapKit for UIKit(https://developer.apple.com/documentation/mapkit/mkmultipolygon).
4
1
685
1w
Apple Maps Server API invalid JWT token
Hello, I'm truing to use Maps Server API. I have: Created Maps Identifier and a Private Key Used token maker to create a JWT token. I also tried creating JWT token manually. After generating a JWT token I used Maps Server API Playground with my JWT and I can successfully use Maps Server API. The problem is that when I try to use my JWT in either JS code, Postman or curl request, I get "Invalid Token" error. Which is very strange, because I doubled checked everything dozen of times and JWT works in Apple's playground tool. Here's a request example: curl -si -H"Authorization: Bearer <jwt token>" "https://maps-api.apple.com/v1/geocode?q=Apple%20Park%2C%20Cupertino%2C%20CA" My token is valid for 1 year When generating JWT token I left "Domain restriction" field empty.
1
1
754
Jun ’24
API Authentication
I am trying to migrate some of my mapkit code to the Map Server API. My JWT is fine and I can use that within the API Playground just fine. However, when I try to implement a test using PHP and cURL to get my Map token, I receive a 401 Not Authorized Error. My code is below: <?php $URL="https://maps-api.apple.com/v1/token"; $accesstoken = "<MY TOKEN HERE>"; $authorization = 'Authorization: Bearer'.$accesstoken; $headers = []; $ch = curl_init($URL); curl_setopt($ch, CURLOPT_HTTPHEADER, [$authorization]); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_HEADERFUNCTION, function($curl, $header) use (&$headers) { $len = strlen($header); $header = explode(':', $header, 2); if (count($header) < 2) // ignore invalid headers return $len; $headers[strtolower(trim($header[0]))][] = trim($header[1]); return $len; } ); $result=curl_exec($ch); $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //get status code curl_close ($ch); print_r($headers); echo($result); echo($status_code); ?> Now the exact response that I am receiving is: Array ( [date] => Array ( [0] => Thu, 18 Apr 2024 18:32:15 GMT ) [content-type] => Array ( [0] => application/json;charset=utf8 ) [content-length] => Array ( [0] => 51 ) [connection] => Array ( [0] => keep-alive ) [cache-control] => Array ( [0] => max-age=0 ) [x-rid] => Array ( [0] => c9507281-bc32-46ac-be3b-dc59e97e7fed ) [strict-transport-security] => Array ( [0] => max-age=31536000; includeSubDomains; ) ) {"error":{"message":"Not Authorized","details":[]}} 401 Any help getting this to work would be appreciated.
1
0
592
Apr ’24
MapKit - Route Drawn and MkStep Direction
I am making an app like Taxi Driving, where users can add location and driver to that location. The problems I am facing are below: Drawing a route on MKMap - I get the route polyline and I render that on the map. Now what should happen as I am driving, the drove part of the polyline should get removed or may be turned grey, non-drove part should be blue. Currently, I am only able to do this by again getting a route from my current location and re-drawing on the map which is not a good thing I suppose. Show driving instructions - I need to show step-by-step instructions which I get in the MKStep under the MKRoute object. But I don't get the icons that I can show such as Turn Right or Turn left the only thing I have is plain text. I need an icon along with it and also how to identify once I have crossed the step and show the next step as my next instruction. These two are the major problems I am facing and I need to do this with Apple native map view itself so no third-party integration I want.
0
1
636
Feb ’24
Maps searchAutoComplete response field "structuredAddress" always null
Regardless of how much information is provided to the Maps searchAutoComplete API, the response field structuredAddress is always null. This means I have to call the completionUrl afterwards to get a structured address. This consumes our quota and causes unnecessary Maps traffic. Example request, autocompleting "450 Post St, San Francisco": https://maps-api.apple.com/v1/searchAutocomplete? q=450%20Post%20St%2C%20San%20Francisco &resultTypeFilter=Address &limitToCountries=US &lang=en-US responds 2 results with the actual address found, but each having only these fields: - completionUrl - displayLines - location Example: { "results": [ { "completionUrl": "/v1/search?q=450%20Post%20St%20San%20Francisco%2C%20CA%2C%20United%20States&metadata=Ch8KCzQ1MCBQb3N0IFN0EgQIABADEgQIBBAEEgQICRACEjQKIFNhbiBGcmFuY2lzY28sIENBLCBVbml0ZWQgU3RhdGVzEgQIGhACEgQIABADEgQIBBAJGAIyRgoSCQAAAEDg5EJAEQAAAOA9ml7AEM6h0aK1wfKqciA5KQAAAAAAAHlAgvEEAzQ1MIjxBDGa8QQCVVOg8QQAsvEEALrxBABiHAoaNDUwIFBvc3QgU3QsIFNhbiBGcmFuY2lzY2%2BC8QQaNDUwIFBvc3QgU3QsIFNhbiBGcmFuY2lzY2%2BI8QQA2vEEFgkAAABAEf3IQBkAAAAAAAAAACABKAPq8QQAkPIEAQ%3D%3D", "displayLines": [ "450 Post St", "San Francisco, CA, United States" ], "location": { "latitude": 37.78809356689453, "longitude": -122.41002655029297 } }, { "completionUrl": "/v1/search?q=450%20Post%20St%20Napa%2C%20CA%2C%20United%20States&metadata=****", "displayLines": [ "450 Post St", "Napa, CA, United States" ], "location": { "latitude": 38.30093002319336, "longitude": -122.27799224853516 } } ] } Anyone figured this out? Seems buggy to me.
0
2
698
Jan ’24
How can obtain Public Transportation Information with MapKit
Can Mapkit show me details about bus stops, train stations, underground and overground stops, or other public transportation locations based on a specific latitude and longitude? If you check the Google Maps picture I shared, I marked all the public transportation spots near Elephant & Castle in London. This includes bus stops, the Elephant & Castle Underground station, and the Elephant & Castle Rail station. Additionally, tapping on these spots brings up an alert with more info, like which buses are coming or details about train lines.
0
0
687
Nov ’23
Google crush my app.
I am currently facing a critical issue with the Google Maps integration in my iOS app. The application functions flawlessly on my personal device during development; however, when I upload it to the Apple Store, users on their iPhones experience frequent crashes. The problem seems to be specifically tied to the Google Maps functionality within the app. Despite thorough testing on my end, the discrepancy between the local environment and the App Store release persists. I am seeking assistance from fellow developers to help me identify and rectify the root cause of this problem. Any insights, suggestions, or debugging tips would be greatly appreciated to ensure a smooth and reliable user experience for all. Thank you in advance for your expertise and support in resolving this issue.
0
0
558
Nov ’23