diff --git a/Starter_Code/static/js/logic.js b/Starter_Code/static/js/logic.js index 6c041bc..ca4b38d 100644 --- a/Starter_Code/static/js/logic.js +++ b/Starter_Code/static/js/logic.js @@ -1,5 +1,9 @@ +//linking to the geojson url to a value to be accessed url = "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson" + +//Creating a value to represent depth depth = function(d){ + //Using if statements to color coordinate based on depth if (d >= 90) { return "maroon"} else if (d>=70){ @@ -15,17 +19,24 @@ depth = function(d){ return "lime" } } +//Jsonifying the URL data via d3 to connect to the html d3.json(url).then(function(eqData){ + //allowing the data to be viewed in the console console.log(eqData) + // creating a map value to access the map div tag in html map = L.map("map",{ center:[0,0], zoom: 2 }) + // Using Leaflet to choose the tile layer design on the map L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap contributors' }).addTo(map); + // a format for encoding a variety of geographic data structures L.geoJson(eqData,{ + //setting the location of the data on the map pointToLayer:function(feature, cord){ + //Formatting the design of the data return L.circleMarker(cord,{ color: depth(feature.geometry.coordinates[2]), fillColor: depth(feature.geometry.coordinates[2]), @@ -34,19 +45,21 @@ d3.json(url).then(function(eqData){ radius: feature.properties.mag * 10 }) }, + //Allowing a popup display on each displayed feature on the map onEachFeature: function(feature, layer){ layer.bindPopup(`