Skip to content

Instantly share code, notes, and snippets.

@guaracyalima
Created June 15, 2018 03:51
Show Gist options
  • Save guaracyalima/259cf69614fb53f82a70a9685f2aa73f to your computer and use it in GitHub Desktop.
Save guaracyalima/259cf69614fb53f82a70a9685f2aa73f to your computer and use it in GitHub Desktop.
<html>
<head>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css"/>
<script src="http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.js"></script>
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="leaflet-providers.js"></script>
</head>
<body>
<div id="map" style="width: 100%; height: 300px;"></div>
<script type="text/javascript">
var map = L.map('map');
var terrainTiles = L.tileLayer.provider('OpenTopoMap');
terrainTiles.addTo(map);
map.setView([35.9908385, -78.9005222], 3);
function addDataToMap(data, map) {
var dataLayer = L.geoJson(data, {
onEachFeature: function(feature, layer) {
var popupText = "Magnitude: " + feature.properties.mag
+ "<br>Location: " + feature.properties.place
+ "<br><a href='" + feature.properties.url + "'>More info</a>";
layer.bindPopup(popupText); }
});
dataLayer.addTo(map);
}
$.getJSON("https://gist.githubusercontent.com/guaracyalima/5c188a1f5f086b08e315ca45fd1b375f/raw/d1cd1f1522effbe2608c092597488fcd3d5a9097/bsb.geojson", function(data) { addDataToMap(data, map); });
</script>
</body>
</html>
@guaracyalima
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment