A react wrapper for apple mapkit.js
npm install react-apple-mapkitjs``javascript`
npm install react-apple-mapkitjs
Add the script file in your reacts public index.html file
`html`
Getting your token to get mapkitjs to work is not the most simple of tasks, I recommend watching this video in full to understand how to do this.
https://developer.apple.com/videos/play/wwdc2018/508
If you want a simpler explanation and dont mind giving your private key to some other app to create your access token then the following link is a great resource.
https://mapkitjs.rubeng.nl/#/
*
Import the AppleMaps component into your project
`jsx`
import { AppleMaps } from 'react-apple-mapkitjs'
The only prop that is required is the token prop, without this you will get a "initialization failed" in the console
`jsx`
/>
If the access token is correct then the map will default to Leeds, UK
*Additional props and components
The AppleMaps component takes additional props to adjust the map view and zoom level, you can also specify a map width and height. It currently defaults to view height and width.
`jsx`
longitude={30.8008}
latitude={-1.5491}
zoomLevel={1}
height='100px'
width='100px'
/>
You can also use additional Annotation components to put customizable drop pins on your apple map. The Annotation Components must be child components of AppleMaps.
First import both the AppleMaps and the Annotation component
`jsx`
import { AppleMaps, Annotation, ImageAnnotation } from 'react-apple-mapkitjs'`
then add to your react applicationjsx``
longitude={53.8008}
latitude={-1.5491}
zoomLevel={6}
>
latitude={-1.6017}
color="#969696"
title="Apple"
subtitle="work"
selected={true}
glyphText=""
/>
latitude={-1.5017}
color="#349576"
title="New Annotation"
subtitle="work"
selected={false}
/>
latitude={-1.4017}
title="Cat Cafe"
subtitle="scholes"
selected={false}
url='./assets/cat.jpeg'
visible={false}
/>
Most of the props to the Annotation component are self explanatory
*
I'm going to carry on developing this component as it currently only has basic functionality, if there are any requests or you need any anymore help than that provided above then feel free to get in touch