From c08b0465d7215ad0a616f3aa9d15b48f16ccdc25 Mon Sep 17 00:00:00 2001 From: Luis Serota Date: Wed, 12 Oct 2016 18:51:29 -0400 Subject: [PATCH 1/3] Clean push --- index.html | 33 ++++++++++++++++++++++++++++++++- index.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 index.js diff --git a/index.html b/index.html index 6524157..ccfdba2 100644 --- a/index.html +++ b/index.html @@ -1,7 +1,38 @@ + + + + + + - Mashup + Luis Serota Mashup + + + + + + + + + + +

Click anywhere on the map to get the temparature at that location

+ +
Luis Serota
+ +
+ + + + diff --git a/index.js b/index.js new file mode 100644 index 0000000..b449c2e --- /dev/null +++ b/index.js @@ -0,0 +1,33 @@ +mapboxgl.accessToken = 'pk.eyJ1IjoibHVpc3NlIiwiYSI6ImNpdGoyZ3Q1bjA2eGoybm8zdjFrN2RuMmQifQ.xiEfhxmHUIKN3T3frogq4w'; + var map = new mapboxgl.Map({ + container: 'map', // container id + style: 'mapbox://styles/mapbox/streets-v9', //stylesheet location + center: [-74.50, 40], // starting position + zoom: 9 // starting zoom + }); + + // When the map is closed + map.on('click', function(e) { + + + // Get the city name and state of clicked location + $.get("http://api.wunderground.com/api/4a7a94eca1c51547/geolookup/q/" + e.lngLat.lat + "," + e.lngLat.lng + "-122.395234.json", function(data){ + + console.log(data); + + var state = data.location.state; + var city = data.location.city.split(' ').join('_'); // replace spaces with underscores + + + // Get the weather for a US city in JSON + $.get("http://api.wunderground.com/api/4a7a94eca1c51547/conditions/q/" + state + "/" + city + ".json", function(response){ + + console.log(response); + + alert("The temperature in " + city + ", " + state + " is " + response.current_observation.temp_f + " degrees, but feels like " + response.current_observation.feelslike_f + " degrees;"); + + }); + + }); + + }); \ No newline at end of file From 31cc5ebcae785f8fe2568d90e89a89dae851a920 Mon Sep 17 00:00:00 2001 From: Luis Serota Date: Wed, 12 Oct 2016 18:54:32 -0400 Subject: [PATCH 2/3] Fixes --- index.html | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index ccfdba2..4b843b3 100644 --- a/index.html +++ b/index.html @@ -23,17 +23,11 @@ text-align: center; } - + +

Click anywhere on the map to get the temparature at that location

-
Luis Serota
-
- - - - - - + From 27d1fd4a0dc13d90a9440413587a6d2aba929af3 Mon Sep 17 00:00:00 2001 From: Luis Serota Date: Wed, 12 Oct 2016 19:00:14 -0400 Subject: [PATCH 3/3] fixed script tag --- index.html | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 4b843b3..09882f5 100644 --- a/index.html +++ b/index.html @@ -1,24 +1,20 @@ + - - Luis Serota Mashup - - - +