Skip to content

roblabs/apple-maps-web-snapshot-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

16 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Maps Web Snapshot

At WWDC 2019, Apple announced Maps Web Snapshots for creating a static map from a URL.

Usage

Update your credentials in config.json then install and run.

# config.json
#   Do not commit your secrets
{
  "teamId":             "XXXXXXXXXX",
  "keyId":              "YYYYYYYYYY"
  "privateKey": "AuthKey_YYYYYYYYYY.p8",
}
# install
npm install

# run and inspect output
mapkit-snapshots.js null-island.geojson -c config.json

Online help

Online help is available by supplying no parameters.

mapkit-snapshots.js
Usage:
  mapkit-snapshots.js <file.geojson> -c config.json     # -c pass in privateKey, teamId, keyId
  mapkit-snapshots.js <file.geojson> -c config.json -o  # -o opens in default browser

Generate a URL to display a map from a Apple Maps Web Snapshot.

Find the source code at roblabs/apple-maps-web-snapshot-cli

See the sample GeoJSON, null-island.geojson for example valid properties

"properties": {
  "center": [20, 20],
  "display_point": {
    "type": "Point","coordinates": [10,10]
  },
  "z": 2,
  "spn": [1.0, 1.0],
  "size": [600, 400],
  "scale": 1,
  "t": "mutedStandard",
  "colorScheme": "dark",
  "poi": 1,
  "lang": "en-US",
  "annotations": [],
  "overlays": [],
  "referer": "",
  "expires": 3155673601
}

Apple MapKit JS Examples

This repo shows working samples of Maps Web Snapshots and Node JS sample code for generating the proper URLs to use in your applications.

Snapshot Parameters or Documenation from Create a Maps Web Snapshot Parameter examples
center - The center of the map. You can specify center as coordinates or as an address.
signIt("center=0,0")
signIt("center=37.839622,-119.515182")
signIt("center=San%20Diego,%20California")
size & scale - size - The width and height must be within the range of [50, 640]. Default: 600x400. scale - The pixel density of the image. scale=2 returns an image intended for 2ร— Retina displays.
signIt("center=San%20Diego,%20California&scale=1")
signIt("center=San%20Diego,%20California&scale=2")
t - The map type. Possible values: standard, hybrid, satellite, mutedStandard
signIt("center=37.839622,-119.515182&t=standard")
signIt("center=37.839622,-119.515182&t=hybrid")
signIt("center=37.839622,-119.515182&t=satellite")
signIt("center=37.839622,-119.515182&t=mutedStandard")
signIt("center=San%20Diego,%20California&t=standard")
signIt("center=San%20Diego,%20California&t=hybrid")
signIt("center=San%20Diego,%20California&t=satellite")
signIt("center=San%20Diego,%20California&t=mutedStandard")
colorScheme - The color scheme of the map. Possible values: light, dark. The dark color scheme only applies to the standard and mutedStandard map types.
signIt("center=San%20Diego,%20California&t=standard&colorScheme=light")
signIt("center=San%20Diego,%20California&t=standard&colorScheme=dark")
signIt("center=San%20Diego,%20California&t=mutedStandard&colorScheme=light")
signIt("center=San%20Diego,%20California&t=mutedStandard&colorScheme=dark")
z - The zoom level of the map.
signIt("center=37.839622,-119.515182&z=15")
signIt("center=37.839622,-119.515182&z=14")
signIt("center=37.839622,-119.515182&z=13")
signIt("center=37.839622,-119.515182&z=12")
signIt("center=37.839622,-119.515182&z=11")
signIt("center=37.839622,-119.515182&z=10")
signIt("center=37.839622,-119.515182&z=9")
poi - A Boolean value indicating whether points of interest are shown on the map.
signIt("center=San%20Francisco,%20California&t=mutedStandard&poi=0")
signIt("center=San%20Francisco,%20California&t=mutedStandard&poi=1")
lang - The language to be used for labels on the map, Supported values are in locale IDs, such as en-GB or es-MX.
signIt("center=37.839622,-119.515182&z=3&lang=ar-AR")
signIt("center=37.839622,-119.515182&z=3&lang=de-DE")
signIt("center=37.839622,-119.515182&z=3&lang=en-US")
signIt("center=37.839622,-119.515182&z=3&lang=es-MX")
signIt("center=37.839622,-119.515182&z=3&lang=es-ES")
signIt("center=37.839622,-119.515182&z=3&lang=el-GR")
signIt("center=37.839622,-119.515182&z=3&lang=fi-FI")
signIt("center=37.839622,-119.515182&z=3&lang=fr-FR")
signIt("center=37.839622,-119.515182&z=3&lang=ja-JA")
signIt("center=37.839622,-119.515182&z=3&lang=hu-HU")
signIt("center=37.839622,-119.515182&z=3&lang=it-IT")
signIt("center=37.839622,-119.515182&z=3&lang=ko-KO")
signIt("center=37.839622,-119.515182&z=3&lang=nl-NL")
signIt("center=37.839622,-119.515182&z=3&lang=no-NO")
signIt("center=37.839622,-119.515182&z=3&lang=he-HE")
signIt("center=37.839622,-119.515182&z=3&lang=hi-IN")
signIt("center=37.839622,-119.515182&z=3&lang=pt-BR")
signIt("center=37.839622,-119.515182&z=3&lang=ru-RU")
signIt("center=37.839622,-119.515182&z=3&lang=tr-TR")
signIt("center=37.839622,-119.515182&z=3&lang=vi-VI")
signIt("center=37.839622,-119.515182&z=3&lang=zh-ZH")
annotations - Example of Annotations . The array of JSON Annotation, which draws 3 points: a red dot, a green balloon, & blue large annotations, is shown [{"point":"32.73,-117.19", "color":"blue", "glyphText":"A", "markerStyle":"large"},
{"point":"32.71,-117.17", "color":"00ff00","glyphText":"9", "markerStyle":"balloon"},
{"point":"32.69,-117.16", "color":"red", "glyphText":"a", "markerStyle":"dot"}
]
Live example of Annotations signIt("center=San%20Diego,%20California&<urlEncoded Annotations>")
overlays - Example of Overlays. The array of JSON Overlay objects, which draws a red dashed line over 3 points, is shown:
[{"points":["32.73,-117.19","32.71,-117.17","32.69,-117.16"],
"strokeColor":"ff0000","lineWidth":2,"lineDash":[10,5]}
]
Live example of Overlays signIt("center=San%20Diego,%20California&<urlEncoded Overlay>")
Live example of Annotations & Overlays, together signIt("center=San%20Diego,%20California&<urlEncoded Annotation & Overlay>")

Release Log

  • Dec 30, 2021 - Add output key url to log the signed Apple Maps Web Snapshot URL
  • Nov 04, 2021 - Add command line options: -c for credentials. -o to open in browser.
  • Mar 09, 2020 - Pass in values from GeoJSON. Pass in credentials via config.json.
  • Nov 04, 2019 - Update Javascript example for Annotations & Overlays.
  • Nov 03, 2019 - Initial Sample Code for Maps Web Snapshots with MapKit JS

About

Create static maps ๐Ÿ—บ for Apple Maps using the Maps Web Snapshots announced at WWDC 2019.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published