ol-games/examples/map.explode.html
Jean-Marc Viglino 99cced3283
2017-03-18 17:19:06 +01:00

100 lines
3.3 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>OL3-ext: Map explode</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="An example of ol.featureAnimation to add pulses on a map." />
<meta name="keywords" content="ol3, animation, pulse, map" />
<!-- jQuery -->
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.min.js"></script>
<!-- OL3 -->
<link rel="stylesheet" href="https://openlayers.org/en/master/css/ol.css" />
<script type="text/javascript" src="https://openlayers.org/en/master/build/ol.js"></script>
<!-- OL3-ext -->
<script type="text/javascript" src="https://cdn.rawgit.com/Viglino/ol3-ext/gh-pages/dist/ol3-ext.js"></script>
<script type="text/javascript" src="https://viglino.github.io/ol3-ext/featureanimation/featureanimation.js"></script>
<!-- game -->
<script type="text/javascript" src="../featureanimation/explodeanimation.js"></script>
<script type="text/javascript" src="../media/ol.media.js"></script>
<script type="text/javascript" src="../media/ol.media.audio.js"></script>
<link rel="stylesheet" href="style.css" />
</head>
<body >
<a href="https://github.com/Viglino/ol3-games"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"></a>
<a href="../index.html">
<h1>OL3-ext: Map explode</h1>
</a>
<p class="info">
This example use <i>ol.featureAnimation</i> to add explosions on a map.
</p>
<!-- DIV pour la carte -->
<div id="map" style="width:600px; height:400px;"></div>
<div class="options">
<h2>Options:</h2>
<p>
<i>Click on the map to create an explosion!</i>
</p>
</div>
<script type="text/javascript">
// Layers
var layer = new ol.layer.Tile({
name: "Natural Earth",
minResolution: 306,
source: new ol.source.XYZ(
{ url: 'https://{a-d}.tiles.mapbox.com/v3/mapbox.natural-earth-hypso-bathy/{z}/{x}/{y}.png',
crossOrigin: "Anonymous",
attributions: [new ol.Attribution({ html: '&copy; <a href="https://www.mapbox.com/map-feedback/">Mapbox</a> ' })]
})
});
// The map
var map = new ol.Map
({ target: 'map',
view: new ol.View
({ zoom: 5,
center: [166326, 5992663]
}),
layers: [layer]
});
// Sound
var boom = new ol.media.Audio({ source:"sound/268828.mp3" });
// Pulse feature at coord
function explode(coord)
{ var f = new ol.Feature (new ol.geom.Point(coord));
var anim = new ol.featureAnimation.Explode(
{ duration:3000,
easing: ol.easing.easeOut
});
map.animateFeature (f, anim);
boom.play(0);
}
// Pulse on click
map.on('singleclick', function(evt)
{ explode(evt.coordinate);
});
</script>
</body>
</html>