Skip to content

Instantly share code, notes, and snippets.

@mollietaylor
Created January 3, 2014 01:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mollietaylor/8230639 to your computer and use it in GitHub Desktop.
Save mollietaylor/8230639 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {
"name": "<a href='http://www.freesound.org/people/genghis%20attenborough/sounds/212798/'>Deep basement</a>",
"html": "<p><audio width='300' height='32' src='http://www.freesound.org/data/previews/212/212798_205108-lq.mp3' controls='controls'><br />Your browser does not support the audio element.<br /></audio></p>"
},
"geometry": {
"type": "Point",
"coordinates": [-100,34]
}
},{
"type": "Feature",
"properties": {
"name": "<a href='http://www.freesound.org/people/John%20Sipos/sounds/125696/'>Atlantis docks then lands.</a>",
"html": "<p><audio width='300' height='32' src='http://www.freesound.org/data/previews/125/125696_593024-lq.mp3' controls='controls'><br />Your browser does not support the audio element.<br /></audio></p>"
},
"geometry": {
"type": "Point",
"coordinates": [-84,40]
}
}
]
}
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<head>
<title>Audio Demo</title>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.css" />
<!--[if lte IE 8]>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.ie.css" />
<![endif]-->
<script src="http://cdn.leafletjs.com/leaflet-0.6.4/leaflet.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script type="text/javascript" src="leaflet.ajax.js"></script>
<style type="text/css">
html {
height: 100%;
}
body {
height: 100%;
}
#map {
height: 95%;
}
</style>
</head>
<body>
<div id="map"></div>
<script type="text/javascript">
var map = L.map('map').setView([34, -100], 4);
var audioIcon = L.icon({
iconUrl: 'audio.png',
iconSize: [32, 37],
shadowSize: [0, 0],
iconAnchor: [16, 37],
shadowAnchor: [0, 0],
popupAnchor: [0, -37]
});
function onEachAudio(feature, layer) {
layer.bindPopup(feature.properties.name + "<br>" + feature.properties.html);
};
new L.GeoJSON.AJAX("audio.geojson", {
onEachFeature: onEachAudio,
pointToLayer: function(feature, latlng) {
return L.marker(latlng, {icon: audioIcon});
}
}).addTo(map);
L.tileLayer('http://{s}.tile.stamen.com/watercolor/{z}/{x}/{y}.png',
{
attribution: '<a href="http://maps.stamen.com/">Stamen base map</a>',
maxZoom: 18
}).addTo(map);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment