I need to activate / deactivate direction arrows on Mapillary images in a web application built on Mapillary JS.
I’ve tried to build a little code sample to explain …
Here you are the code
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://unpkg.com/mapillary-js@2.5.0/dist/mapillary.min.js'></script>
<link href='https://unpkg.com/mapillary-js@2.5.0/dist/mapillary.min.css' rel='stylesheet' />
<style>
html, body { margin: 0; padding: 0; height: 100%; }
</style>
</head>
<body>
<div id="titlebar">
<center>
Select option:
<select onchange="onSelect.call(this, event)">
<option value="with">With arrows</option>
<option value="without">Without arrows</option>
</select>
</center>
</div>
<div id="xxx">
<table border=1>
<div id="mly" style="width:100%;height:100%">
</div>
</table>
</div>
<script>
var pegman_position = {lat: 42.628386111111126, lng: 13.291408333333237};
var mly = new Mapillary.Viewer(
'mly',
// Replace this with your own client ID from mapillary.com
'QjI1NnU0aG5FZFZISE56U3R5aWN4ZzowODkzY2RjNjM1ZmEwYTVi',
'Sx1k3lLpdFU1TWS-8u_Y-w',
{
component: {
cover: false,
direction: false
}
}
);
mly.setCenter(pegman_position.lat, pegman_position.lon);
// Viewer size is dynamic so resize should be called every time the window size changes
window.addEventListener("resize", function() { mly.resize(); });
function onSelect(event) {
switch (this.options[this.selectedIndex].text) {
case "With arrows":
var theComponent = mly.getComponent('direction');
theComponent.configure({direction: true});
break;
case "Without arrows":
break;
}
}
</script>
</body>
</html>
The initial situation is WITHOUT the direction arrows as you can see because I start with this configuration
{
component: {
cover: false,
direction: false
}
}
I’d like to modify it using a selection above the image and if I select “With arrows” I’d like to show the arrows …
I’ve tried to manage this situation with this code …
case "With arrows":
var theComponent = mly.getComponent('direction');
theComponent.configure({direction: true});
break;
that execute without errors but no changes are on my Mapillary image …
Suggestions / examples?
Thank you in advance!
Cesare