Skip to content

Instantly share code, notes, and snippets.

@oscarlorentzon
Last active January 20, 2021 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oscarlorentzon/a9bd5d6dadcc5df7e024a04a9600b043 to your computer and use it in GitHub Desktop.
Save oscarlorentzon/a9bd5d6dadcc5df7e024a04a9600b043 to your computer and use it in GitHub Desktop.
MapillaryJS + ESRI JS API
<!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://js.arcgis.com/3.17/esri/css/esri.css' rel='stylesheet' />
<script src='https://js.arcgis.com/3.17/'></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>
require([
'esri/map',
'esri/graphic',
'esri/geometry/Point',
'esri/symbols/SimpleMarkerSymbol',
'https://unpkg.com/mapillary-js@3.1.0/dist/mapillary.min.js',
'dojo/domReady!'
], function (Map, Graphic, Point, MarkerSymbol, Mapillary) {
var mapOptions = {
center: [12.695600612967427, 56.04351888068181],
zoom: 15,
basemap: 'osm',
};
var map = new Map('map', mapOptions);
var mly = new Mapillary.Viewer({
apiClient: 'QjI1NnU0aG5FZFZISE56U3R5aWN4Zzo3NTM1MjI5MmRjODZlMzc0',
container: 'mly',
imageKey: 'zarcRdNFZwg3FkXNcsFeGw',
});
var marker;
mly.on(Mapillary.Viewer.nodechanged, function (node) {
var lonLat = [node.latLon.lon, node.latLon.lat];
if (!marker) {
var symbolJson = {
type: 'esriSMS',
style: 'esriSMSCircle',
color: [54, 175, 109, 255],
outline: {
color: [255, 255, 255],
width: 2,
},
};
marker = new Graphic(
new Point(lonLat),
new MarkerSymbol(symbolJson));
if (map.loaded) {
map.graphics.add(marker);
} else {
map.on('load', function() {
map.graphics.add(marker);
});
}
} else {
marker.setGeometry(new Point(lonLat));
}
map.centerAt(new Point(lonLat));
});
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