From 817cc94a3fb178d03097f953d1319b36df1a8a1f Mon Sep 17 00:00:00 2001 From: Jorge Sierra <3d.jorgesierra@gmail.com> Date: Sun, 24 Mar 2019 08:18:51 -0400 Subject: [PATCH 1/8] initial commit --- assets/javascript/Geofire.js | 0 assets/javascript/main.js | 83 +++++++++++++++++++++++++++++++--- assets/javascript/main_edua.js | 81 --------------------------------- index.html | 65 +++----------------------- 4 files changed, 83 insertions(+), 146 deletions(-) create mode 100644 assets/javascript/Geofire.js delete mode 100644 assets/javascript/main_edua.js diff --git a/assets/javascript/Geofire.js b/assets/javascript/Geofire.js new file mode 100644 index 0000000..e69de29 diff --git a/assets/javascript/main.js b/assets/javascript/main.js index ef83203..eb99ed8 100644 --- a/assets/javascript/main.js +++ b/assets/javascript/main.js @@ -23,15 +23,16 @@ function getGeoLocation() { var pLocation = $("
"); pLocation.text("The Lattitude-array: " + userLocation[0] + " and the longitude-array: " + userLocation[1]); + //update maps + googleMapsLoad(userLocation[0], userLocation[1]); + + //update body $("body").append(pLocation); - }); + }); } else { console.log("no access to geto") } - console.log("console lat - " + userLocation[0] + " console long - " + userLocation[1]); - - // this is the call for YELP QUERY - WORKING var yelpQuery = "https://cors-anywhere.herokuapp.com/https://api.yelp.com/v3/businesses/search?term=delis&latitude=39.951061&longitude=-75.165619&radius=8000"; @@ -48,12 +49,82 @@ function getGeoLocation() { }, method: "GET" }).then((yelpResponse) => { - console.log(yelpResponse); - } + console.log(yelpResponse); + } ); } +//google map function of generating user and icon +function googleMapsLoad(userLat, userLng) { + + // initialize maps + + var map = new google.maps.Map(document.getElementById("map"), { + zoom: 20, + center: { + lat: userLat, + lng: userLng + } + }); + + var allUsers = [ + + firstUser = { + coords: { + lat: userLat, + lng: userLng, + radius: 10 + }, + iconImage: "./assets/images/map-icon.png", + content: "
"); - - //Note 1: This output doesn't show until I accept "Allow Location" - pLocation.text("The Lattitude-array: " + userLocation[0] + " and the longitude-array: " + userLocation[1]); - - $("body").append(pLocation); - - } ); - } else { - console.log("no access to geto") - } - - //Note 2: This output shows up right after I press the button - console.log("console lat - " + userLocation[0] + " console long - " + userLocation[1]); - - //Note 3: Conclusion: The function declares the variables ONLY when the "Allow location" is accpected. Otherwise, the variable is undefined - // You were leaning this way but it's important to know (I believe) that the part where the location data is gathered is asynchronos to the line at 43. - // Which is to say that you will get the output of the console log before the location value actually set. - -// this is the call for YELP QUERY -// var yelpQuery = "https://cors-anywhere.herokuapp.com/https://api.yelp.com/v3/businesses/search?term=delis&latitude=39.951061&longitude=-75.165619&radius=8046.72"; -//testing to see if I can get variables included - - var yelpQuery = "https://cors-anywhere.herokuapp.com/https://api.yelp.com/v3/businesses/search?term=delis&latitude=" + userLocation[0] + "&longitude=" + userLocation[1] + "&radius=8000"; - var yelpAPI = "1QpSc4B1zI5GuI56PDAAvAfpfcsLg9LWuHRfVCeG4TIDDxRe3hGT-sxlU5h5DD0AdLgu-HHoa2cM4m1WaAefYoboIPdVHv0mCjivrwQrdU11FCFl2hd8-iaaTKOTXHYx"; - - - console.log(yelpQuery); - $.ajax({ - url: yelpQuery, - headers: { - 'Authorization': "Bearer " + yelpAPI, - }, - method: "GET" - }).then((yelpResponse) => { - console.log(yelpResponse); - } - - ); -} - -$(document).on("click", "#getGeoLocation", getGeoLocation); - -// getGeoLocation(); - - - -//firebase Google Maps API -//https://www.google.com/maps/embed/v1/MODE?key=AIzaSyCHREkl-BVxFLXW5Hp_reWCSnIDK-Oq2Wk¶meters - - -// Execute functions \ No newline at end of file diff --git a/index.html b/index.html index 9fcfb00..eef3e96 100644 --- a/index.html +++ b/index.html @@ -26,74 +26,20 @@