Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created January 17, 2019 15:34
Show Gist options
  • Save azamsharp/f25e3aefac36b864004e421cfda3dcc4 to your computer and use it in GitHub Desktop.
Save azamsharp/f25e3aefac36b864004e421cfda3dcc4 to your computer and use it in GitHub Desktop.
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.apple-mapkit.com/mk/5.x.x/mapkit.js"></script>
<style>
#map {
width: 100%;
height: 600px;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
mapkit.init({
authorizationCallback: function(done) {
fetch('/services/jwt')
.then(response => response.json())
.then(result => {
done(result.token)
})
}
});
var MarkerAnnotation = mapkit.MarkerAnnotation
var sfo = new mapkit.Coordinate(37.616934, -122.383790)
var sfoRegion = new mapkit.CoordinateRegion(
new mapkit.Coordinate(37.616934, -122.383790),
new mapkit.CoordinateSpan(0.167647972, 0.354985255)
);
var map = new mapkit.Map("map");
var sfoAnnotation = new MarkerAnnotation(sfo, { color: "#f4a56d", title: "SFO", glyphText: "✈️" });
map.showItems([sfoAnnotation]);
map.region = sfoRegion;
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment