Last active
January 20, 2021 08:33
-
-
Save oscarlorentzon/fda7ce2bdae8499580b1f72d139103de to your computer and use it in GitHub Desktop.
MapillaryJS + Google Maps
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'/> | |
<script src='https://unpkg.com/mapillary-js@3.1.0/dist/mapillary.min.js'></script> | |
<script src='https://maps.googleapis.com/maps/api/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 mapOptions = { | |
center: { lat: 56.04351888068181, lng: 12.695600612967427 }, | |
zoom: 15, | |
streetViewControl: false, | |
mapTypeId: google.maps.MapTypeId.ROADMAP, | |
}; | |
var map = new google.maps.Map(document.getElementById('map'), mapOptions); | |
var mly = new Mapillary.Viewer({ | |
apiClient: 'QjI1NnU0aG5FZFZISE56U3R5aWN4Zzo3NTM1MjI5MmRjODZlMzc0', | |
container: 'mly', | |
imageKey: 'zarcRdNFZwg3FkXNcsFeGw', | |
}); | |
var marker; | |
mly.on(Mapillary.Viewer.nodechanged, function (node) { | |
var latLng = { lat: node.latLon.lat, lng: node.latLon.lon }; | |
if (!marker) { | |
marker = new google.maps.Marker({ | |
position: latLng, | |
map: map, | |
}); | |
marker.setMap(map) | |
} else { | |
marker.setPosition(latLng); | |
} | |
map.setCenter(latLng); | |
}); | |
window.addEventListener('resize', function() { mly.resize(); google.maps.event.trigger(map, "resize"); }); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment