mirror of
https://github.com/Viglino/ol-games.git
synced 2026-01-18 15:17:17 +00:00
99 lines
2.7 KiB
HTML
99 lines
2.7 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<!--
|
|
Copyright (c) 2017 Jean-Marc VIGLINO,
|
|
released under CeCILL-B (french BSD like) licence: http://www.cecill.info/
|
|
-->
|
|
<title>ol-games: Sounds!</title>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
|
|
<meta name="description" content="Usefull class to handle audio in il3-games" />
|
|
<meta name="keywords" content="ol, game, audio, sound, media" />
|
|
|
|
<link rel="stylesheet" href="style.css" />
|
|
|
|
<!-- jQuery -->
|
|
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
|
|
<!-- FontAwesome -->
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
|
|
|
<!-- OpenLayers -->
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ol@latest/ol.css" />
|
|
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ol@latest/dist/ol.js"></script>
|
|
|
|
<!-- ol-ext -->
|
|
<link rel="stylesheet" href="https://viglino.github.io/ol-ext/dist/ol-ext.css" />
|
|
<script type="text/javascript" src="https://viglino.github.io/ol-ext/dist/ol-ext.js"></script>
|
|
|
|
<!-- ol-games -->
|
|
<link rel="stylesheet" href="../dist/ol-games.css" />
|
|
<script type="text/javascript" src="../dist/ol-games.js"></script>
|
|
|
|
|
|
<style>
|
|
#map {
|
|
position: absolute;
|
|
top:4.5em; bottom:0;
|
|
left:0; right: 0;
|
|
margin: 0;
|
|
}
|
|
.options {
|
|
position:absolute;
|
|
right: 1em;
|
|
}
|
|
</style>
|
|
|
|
</head>
|
|
<body >
|
|
<a href="https://github.com/Viglino/ol-games" class="icss-github-corner"><i></i></a>
|
|
|
|
<a href="../">
|
|
<h1>ol-games: Sounds!</h1>
|
|
</a>
|
|
<div class="info">
|
|
</div>
|
|
|
|
<!-- Map div -->
|
|
<div id="map"></div>
|
|
|
|
<div class="options" >
|
|
<h2>Options:</h2>
|
|
Click or move the map to play a sound.
|
|
</div>
|
|
|
|
|
|
<script type="text/javascript">
|
|
// Layers
|
|
var layers = [ new ol.layer.Tile({ preload:Infinity, source: new ol.source.StadiaMaps({ layer: 'stamen_watercolor' }) }) ];
|
|
|
|
// The map
|
|
var map = new ol.Map ({
|
|
target: 'map',
|
|
view: new ol.View ({
|
|
zoom: 11,
|
|
center: [260064, 6250762]
|
|
}),
|
|
layers: layers
|
|
});
|
|
|
|
// Boing on click
|
|
var boing = new ol.media.Audio({ source:"sound/383240.mp3" });
|
|
map.on('click', function(e) {
|
|
boing.play(0);
|
|
});
|
|
|
|
// Slide sound while panning the map
|
|
var slide = new ol.media.Audio({ source:"sound/51132.mp3", loop:true });
|
|
// map.on('movestart', function(e)
|
|
map.getView().on('propertychange', function(e) {
|
|
slide.play();
|
|
});
|
|
map.on('moveend', function(e) {
|
|
slide.stop();
|
|
});
|
|
|
|
</script>
|
|
|
|
</body>
|
|
</html> |