Advertisement
Guest User

initMap function

a guest
May 9th, 2020
744
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function initMap(){
  2.   const map = new google.maps.Map(document.getElementById('map'), {
  3.           center: {lat: 34.23833238, lng: -118.523664572},
  4.           zoom: 16,//15.8,
  5.           gestureHandling: "none",
  6.           disableDefaultUI: true,
  7.           clickableIcons: false
  8.         });
  9.  
  10.     map.addListener("dblclick", e => {
  11.       console.log("I just double clicked!!!", e);
  12.       const geoCoder = new google.maps.Geocoder();
  13.  
  14.       geoCoder.geocode({latLng: e.latLng}, (results, status) => {
  15.         if (status = google.maps.GeocoderStatus.OK) {
  16.           console.log('results from geocode api: ', results)
  17.         }
  18.       })
  19.     });
  20.     //generate list of possible CSUN locations
  21.     const listOfPlaces = ["Where is Bayramian Hall", "Where is the Student Recreation Center", "Where is Jacaranda Hall", "Where is Juniper Hall", "Where is Redwood Hall", "Where is Matador Bookstore"];
  22.     listOfPlaces.sort(() => 0.5 - Math.random());
  23.     const currentQuestions = listOfPlaces.slice(0, 5);
  24.     const currentQuestionIndex = 0;
  25.     console.log('five selected questions', currentQuestions);
  26.     document.getElementById("instructions").innerHTML += `<p>${currentQuestions[currentQuestionIndex]}</p>`;
  27. }
  28.  
  29. var rectangle = new google.maps.Rectangle({
  30. strokeColor: '#FF0000',
  31. strokeOpacity: 0.8,
  32. strokeWeight: 2,
  33. fillColor: '#FF0000',
  34. fillOpacity: 0.35,
  35. map: map,
  36. bounds: {
  37.   north: 34.23833238,
  38.   south: 34.2383329,
  39.   east: -118.523664572,
  40.   west: -118.9
  41. });
  42.  
  43. /*
  44.  
  45. //generate list of possible CSUN locations
  46. const listOfPlaces = ["Bayramian Hall", "Student Recreation Center", "Jacaranda Hall", "Juniper Hall", "Redwood Hall", "Matador Bookstore"];
  47.  
  48. //function for wrong answer
  49. function makeRed(userAnswer) {
  50.   console.log("make red");
  51.  });
  52.   //turn the user answer on the map red
  53. }
  54.  
  55. //function for right answer
  56. function makeGreen(userAnswer){
  57.   console.log("make green");
  58.   //turn the user answer on the map green
  59. }
  60.  
  61. //function to prompt user
  62. function promptUser(userAnswer){
  63.   console.log("click on an object");
  64.   //ask user to double click on a place
  65.   //userAnswer.addEventListener("click", rightOrWrong(userAnswer);
  66.   const findPlace  = listOfPlaces.find(place => place === userAnswer);
  67.   if(listOfPlaces[userAnswer].ondblclick()){
  68.     rightOrWrong(userAnswer);
  69.   }
  70. }
  71.  
  72. var rightAnswers=0;
  73. //function that determines if user is right or wrong
  74. function rightOrWrong(userAnswer) {
  75.   if (userAnswer === correctAnswer) {
  76.     document.write(`<p>You got it right!!!<p>`);
  77.  
  78.     //run jQuery function to make clicked place on google green
  79.     console.log("you got it right!");
  80.     makeRed();
  81.     rightAnswers++;
  82.   } else {
  83.     document.write(`<p>You got it wrong!!!</p>`);
  84.     //run jQuery function to make clicked place on google red
  85.     console.log("you get it wrong!");
  86.     makeGreen();
  87.   }
  88. }
  89.  
  90. //for each place on the map
  91. for (var i = 0; i < 5; i++){
  92.  
  93.   //prompt user to click on a location
  94.    promptUser('');
  95.  
  96.   //generate a correct answer to compare this to
  97.    let correctAnswer = listOfPlaces[(Math.random() * listOfPlaces.length()).floor()];
  98.    document.write(`<p>Click on the location of , ${correctAnswer}</p>`);
  99.  
  100.   //some sort of event handler to let the user click on a location, then determine whether they were right or right or wrong
  101.   //based on that click
  102.   let userAnswer=document.getElementById("rightAnswer").addEventListener("click", rightOrWrong());
  103.  
  104.   rightOrWrong(userAnswer);
  105.  
  106.   document.write(`${rightAnswers}/5`);
  107.   document.log("script runs");
  108. }
  109. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement