mapillary-js/debug/markers.html
2017-03-21 09:56:58 +00:00

81 lines
2.5 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>MapillaryJS Markers Debug Page</title>
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<script src='dist/mapillary.js'></script>
<link rel='stylesheet' href='dist/mapillary.min.css' />
<style>
body { margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; }
#viewer { width: 100%; height: 100%; }
</style>
</head>
<body>
<div id='viewer'></div>
<script>
const mly = new Mapillary.Viewer(
'viewer',
'QjI1NnU0aG5FZFZISE56U3R5aWN4ZzpkYzg0NzE3MDA0YTRhZjlh',
null,
{
component: {
cover: false,
marker: true,
},
});
const key = !!window.location.hash ? window.location.hash.substring(1) : '6Zhtztzt67fWmdd4OYH44w';
mly.moveToKey(key)
.then((n) => {
const markers = createRandomMarkers(1000000, n.latLon);
addMarkers(markers);
});
function getRandomUniform(min, max) {
return Math.random() * (max - min) + min;
}
const createRandomMarkers = function(count, latLon) {
const t0 = window.performance.now();
const boxWidth = 0.06;
const minLat = latLon.lat - boxWidth / 2;
const maxLat = latLon.lat + boxWidth / 2;
const minLon = latLon.lon - boxWidth / 2;
const maxLon = latLon.lon + boxWidth / 2;
const markers = [];
for (let i = 0; i < count; i++) {
const lat = getRandomUniform(minLat, maxLat);
const lon = getRandomUniform(minLon, maxLon);
const marker = new Mapillary.MarkerComponent.SimpleMarker(
i.toString(), { lat: lat, lon: lon });
markers.push(marker);
}
const t1 = window.performance.now();
console.log('create markers:', (t1 - t0).toFixed(2));
return markers;
}
const mc = mly.getComponent("marker");
function addMarkers(markers) {
const t0 = window.performance.now();
mc.add(markers);
const t1 = window.performance.now();
console.log('add markers:', (t1 - t0).toFixed(2));
}
window.addEventListener('resize', function() { mly.resize(); });
</script>
</body>
</html>