Skip to content

Instantly share code, notes, and snippets.

@klokan
Created August 8, 2013 01:11
Show Gist options
  • Save klokan/6180581 to your computer and use it in GitHub Desktop.
Save klokan/6180581 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/v1.3.1/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/v1.3.1/mapbox.css' rel='stylesheet' />
<!--[if lte IE 8]>
<link href='//api.tiles.mapbox.com/mapbox.js/v1.3.1/mapbox.ie.css' rel='stylesheet' >
<![endif]-->
</head>
<body>
<div id='map'></div>
<script type='text/javascript'>
var map = L.mapbox.map('map');
L.mapbox.tileLayer('tmcw.map-ajwqaq7t', {
retinaVersion: 'tmcw.map-u8vb5w83',
detectRetina: true
}).addTo(map);
map.attributionControl.addAttribution('<a href="http://geojson.io/">geojson.io</a>');
$.getJSON('map.geojson', function(geojson) {
var geojsonLayer = L.geoJson(geojson).addTo(map);
map.fitBounds(geojsonLayer.getBounds());
geojsonLayer.eachLayer(function(l) {
showProperties(l);
});
});
function showProperties(l) {
var properties = l.toGeoJSON().properties, table = '';
for (var key in properties) {
table += '<tr><th>' + key + '</th>' +
'<td>' + properties[key] + '</td></tr>';
}
if (table) l.bindPopup('<table class="marker-properties display">' + table + '</table>');
}
</script>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
16.5234375,
49.15296965617042
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-1.7578125,
42.553080288955826
],
[
-1.7578125,
49.38237278700955
],
[
8.0859375,
49.38237278700955
],
[
8.0859375,
42.553080288955826
],
[
-1.7578125,
42.553080288955826
]
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
27.421875,
46.55886030311719
],
[
56.6015625,
37.43997405227057
],
[
56.953125,
49.61070993807422
],
[
36.5625,
60.58696734225869
],
[
47.109375,
49.15296965617042
],
[
21.796875,
56.9449741808516
],
[
23.90625,
50.51342652633956
],
[
16.5234375,
40.979898069620155
],
[
28.828124999999996,
34.59704151614417
],
[
35.15625,
37.71859032558816
],
[
27.0703125,
42.032974332441405
],
[
27.421875,
46.55886030311719
]
]
]
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment