Last active
January 20, 2021 08:30
-
-
Save oscarlorentzon/5a0b23ea8259db871bed2a724ee3afec to your computer and use it in GitHub Desktop.
MapillaryJS + Leaflet ESRI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE HTML> | |
<html> | |
<head> | |
<meta charset='utf-8' /> | |
<title></title> | |
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /> | |
<link href='https://unpkg.com/mapillary-js@3.1.0/dist/mapillary.min.css' rel='stylesheet' /> | |
<link href='https://unpkg.com/leaflet@1.0.1/dist/leaflet.css' rel='stylesheet' /> | |
<script src='https://unpkg.com/mapillary-js@3.1.0/dist/mapillary.min.js'></script> | |
<script src='https://unpkg.com/leaflet@1.0.1/dist/leaflet.js'></script> | |
<script src='https://cdn.jsdelivr.net/leaflet.esri/1.0.0/esri-leaflet.js'></script> | |
<style> | |
body { margin:0; padding:0; height: 100%; } | |
#mly { position: absolute; height: 100%; width: 66%; } | |
#map { position: absolute; width: 34%; top: 0; right: 0; bottom: 0; } | |
</style> | |
</head> | |
<body> | |
<div id='mly'></div> | |
<div id='map'></div> | |
<script> | |
var map = L.map('map').setView([56.04351888068181, 12.695600612967427], 15); | |
L.esri.basemapLayer('Topographic').addTo(map); | |
var mly = new Mapillary.Viewer({ | |
container: 'mly', | |
apiClient: 'QjI1NnU0aG5FZFZISE56U3R5aWN4Zzo3NTM1MjI5MmRjODZlMzc0', | |
imageKey: 'zarcRdNFZwg3FkXNcsFeGw', | |
}); | |
var marker; | |
mly.on(Mapillary.Viewer.nodechanged, function (node) { | |
var latLon = [node.latLon.lat, node.latLon.lon]; | |
if (!marker) { | |
marker = L.marker(latLon); | |
marker.addTo(map); | |
} else { | |
marker.setLatLng(latLon); | |
} | |
map.setView(latLon); | |
}); | |
window.addEventListener('resize', function() { mly.resize(); }); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment