Last active
April 4, 2023 11:23
-
-
Save chrisarusso/d7d54a4149830a8baa6d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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("http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson", function(data) { addDataToMap(data, map); }); | |
</script> | |
</body> | |
</html> |
Is there any way to link to a JSON as a file? So that you could change the data if you wanted to? I've tried several methods that haven't worked.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sorry,can you help me on this case.i have geojson imported in the map but i want apply different markericon on each.
so can you please explain to me