Skip to content

Instantly share code, notes, and snippets.

/index.html Secret

Created July 24, 2017 13:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/884002f66a9533fea99ba15b10b9fb49 to your computer and use it in GitHub Desktop.
Save anonymous/884002f66a9533fea99ba15b10b9fb49 to your computer and use it in GitHub Desktop.
via:geojson.io
<!DOCTYPE html>
<html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no' />
<style>
body { margin:0; padding:0; }
#map { position:absolute; top:0; bottom:0; width:100%; }
.marker-properties {
border-collapse:collapse;
font-size:11px;
border:1px solid #eee;
margin:0;
}
.marker-properties th {
white-space:nowrap;
border:1px solid #eee;
padding:5px 10px;
}
.marker-properties td {
border:1px solid #eee;
padding:5px 10px;
}
.marker-properties tr:last-child td,
.marker-properties tr:last-child th {
border-bottom:none;
}
.marker-properties tr:nth-child(even) th,
.marker-properties tr:nth-child(even) td {
background-color:#f7f7f7;
}
</style>
<script src='//api.tiles.mapbox.com/mapbox.js/v2.2.2/mapbox.js'></script>
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js' ></script>
<link href='//api.tiles.mapbox.com/mapbox.js/v2.2.2/mapbox.css' rel='stylesheet' />
</head>
<body>
<div id='map'></div>
<script type='text/javascript'>
L.mapbox.accessToken = 'pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXFhYTA2bTMyeW44ZG0ybXBkMHkifQ.gUGbDOPUN1v1fTs5SeOR4A';
var map = L.mapbox.map('map');
L.mapbox.tileLayer('mapbox.streets').addTo(map);
$.getJSON('map.geojson', function(geojson) {
var geojsonLayer = L.mapbox.featureLayer(geojson).addTo(map);
var bounds = geojsonLayer.getBounds();
if (bounds.isValid()) {
map.fitBounds(geojsonLayer.getBounds());
} else {
map.setView([0, 0], 2);
}
geojsonLayer.eachLayer(function(l) {
showProperties(l);
});
});
function showProperties(l) {
var properties = l.toGeoJSON().properties;
var table = document.createElement('table');
table.setAttribute('class', 'marker-properties display')
for (var key in properties) {
var tr = createTableRows(key, properties[key]);
table.appendChild(tr);
}
if (table) l.bindPopup(table);
}
function createTableRows(key, value) {
var tr = document.createElement('tr');
var th = document.createElement('th');
var td = document.createElement('td');
key = document.createTextNode(key);
value = document.createTextNode(value);
th.appendChild(key);
td.appendChild(value);
tr.appendChild(th);
tr.appendChild(td);
return tr
}
</script>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"marker-color":"#3465a4","marker-size":"medium","marker-symbol":"rail","title":"Manchester Oxford Road","description":"Closest train station to venue"},"geometry":{"type":"Point","coordinates":[-2.2422,53.4739]}},{"type":"Feature","properties":{"marker-color":"#ff9a00","marker-size":"medium","marker-symbol":"lodging","title":"GUADEC Accomodation","description":"Reception for University student accommodation"},"geometry":{"type":"Point","coordinates":[-2.2485,53.46706]}},{"type":"Feature","properties":{"marker-color":"#0092ff","marker-size":"medium","marker-symbol":"star","title":"Kro Bar","description":"Preregistration Event"},"geometry":{"type":"Point","coordinates":[-2.2318,53.46482]}},{"type":"Feature","properties":{"marker-color":"#0092ff","marker-size":"medium","marker-symbol":"star","title":"The Wharf","description":"Dinner and Games on Friday Night"},"geometry":{"type":"Point","coordinates":[-2.25679,53.47361]}},{"type":"Feature","properties":{"marker-color":"#0092ff","marker-size":"medium","marker-symbol":"star","title":"Manchester Museum of Science and Industry","description":"GNOME 20th Anniversary Party"},"geometry":{"type":"Point","coordinates":[-2.25423,53.47722]}},{"type":"Feature","properties":{"marker-color":"#0092ff","marker-size":"medium","marker-symbol":"star","title":"Turing Tap","description":"Sunday Pub Night"},"geometry":{"type":"Point","coordinates":[-2.229277789592743,53.46252232789993]}},{"type":"Feature","properties":{"marker-color":"#73d216","marker-size":"medium","marker-symbol":"building","title":"Brooks Building","description":"Venue for the core days"},"geometry":{"type":"Point","coordinates":[-2.24643,53.46672]}},{"type":"Feature","properties":{"marker-color":"#73d216","marker-size":"medium","marker-symbol":"building","title":"The Shed","description":"Venue for the unconference days (BoF)"},"geometry":{"type":"Point","coordinates":[-2.24149,53.47136]}}]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment