Skip to content

Instantly share code, notes, and snippets.

@drushadrusha
Created August 22, 2024 22:02
Show Gist options
  • Select an option

  • Save drushadrusha/76282a2cf2a74738292d156c2b2e49b4 to your computer and use it in GitHub Desktop.

Select an option

Save drushadrusha/76282a2cf2a74738292d156c2b2e49b4 to your computer and use it in GitHub Desktop.
Create static MapKit snapshot using PHP
<?php
// composer require mapkit/jwt
require_once('vendor/autoload.php');
use Mapkit\JWT;
$privateKey = file_get_contents('private.p8'); // Private key
$teamId = ''; // Team ID
$keyId = ''; // Key ID
$snapshotPath = "/api/v1/snapshot?center='".$lat.",".$lng."'&size=400x120&scale=2&z=9";
$signature = JWT::getToken($privateKey, $keyId, $teamId);
$path = "$snapshotPath&token=$signature";
$imageurl = "https://snapshot.apple-mapkit.com".$path;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment