nbolender/mapkit-web-snapshot

Generate a signed URL to an Apple MapKit Web Snapshot.

v1.0.0 2021-02-03 07:03 UTC

This package is auto-updated.

Last update: 2025-06-14 13:10:02 UTC


README

PHP library that generates a signed URL to an Apple Maps Web Snapshot.

Install

composer require nbolender/mapkit-web-snapshot

Usage

use NBolender\MapKit\WebSnapshot;

$teamId = 'XXXXXXXXXX'; // Apple Developer Team ID
$keyId = 'XXXXXXXXXX'; // Apple MapKit Key ID
$private_key = '-----BEGIN PRIVATE KEY-----
...
-----END PRIVATE KEY-----'; // Contents of, or path to, private key file
$center = 'One Apple Park Way, Cupertino, CA 95014'; // The center of the map, specified as either coordinates or an address

// (Optional) A keyed array of any additional map parameters; JSON parameters will be automatically encoded
$additional_parameters = [
    'z' => 12,
    'size' => '300x300',
    't' => 'standard',
    'colorScheme' => 'dark',
    'annotations' => [
        [
            'color' => 'ff0000',
            'markerStyle' => 'balloon',
            'point' => 'center',
        ],
    ],
];

$url = WebSnapshot::signedURL($teamId, $keyId, $private_key, $center, $additional_parameters);
echo $url;

Apple Documentation

License

This project is open-source software and licensed under the MIT license.

Credits

This project is developed by Nathan Bolender. Special thanks to Thomas Schoffelen and his MapKit JWT library, which was referenced for this project.