src/main/resources/public/geolocation.js
//geocoder messes up with indexes so global var that represents index is needed
geocoder messes up with indexes so global var that represents index is needed
geocoder messes up with indexes so global var that represents index is needed
function geocodeAddress(address, option, i) {
  geocoder.geocode({ address: address }, function (results, status) {
    if (status == "OK") {
      if (option == 0) {
        var latDiff = Math.abs(
          Math.abs(latitude) - Math.abs(results[0].geometry.location.lat())
        );
        var lngDiff = Math.abs(
          Math.abs(longitude) - Math.abs(results[0].geometry.location.lng())
        );
        if (latDiff <= 0.1 && lngDiff <= 0.1) {
          var marker = new google.maps.Marker({
            map: map,
            position: results[0].geometry.location,
            icon: "https://img.icons8.com/color/48/000000/restaurant-.png",
            Title: "" + i, 
          });
          markerFunctionality(marker, 0); 
          markers.push(marker);
        }
      } else if (option == 2) {
        var marker = new google.maps.Marker({
          map: map,
          position: results[0].geometry.location,
          icon: "https://img.icons8.com/nolan/64/star.png",
          Title: "" + i, 
        });
        markerFunctionality(marker, 2); 
        markers.push(marker);
      } else {
        if (userMarker == null) {
          userLocation = results[0].geometry.location;
          latitude = results[0].geometry.location.lat();
          longitude = results[0].geometry.location.lng();
          converUserLocationToReadableAddressSetup();
          userMarker = new google.maps.Marker({
            position: userLocation,
            map: map,
            icon: "https://img.icons8.com/ios-filled/50/000000/men-age-group-4.png",
          });
          markerFunctionality(userMarker, 1);
        } else {
          userLocation = results[0].geometry.location;
          latitude = results[0].geometry.location.lat();
          longitude = results[0].geometry.location.lng();
          converUserLocationToReadableAddressSetup();
          userMarker.setPosition(userLocation);
          markerFunctionality(userMarker, 1);
          deleteMarkers(); 
          populateRestaurants();
        }
      }
    } else {
      alert("Geocode was not successful for the following reason: " + status);
    }
  });
}
function geocodeAddress ( address , option , i ) { geocoder . geocode ( { address : address } , function ( results , status ) { if ( status == "OK" ) { if ( option == 0 ) { var latDiff = Math . abs ( Math . abs ( latitude ) - Math . abs ( results [ 0 ] . geometry . location . lat ( ) ) ) ; var lngDiff = Math . abs ( Math . abs ( longitude ) - Math . abs ( results [ 0 ] . geometry . location . lng ( ) ) ) ; if ( latDiff <= 0.1 && lngDiff <= 0.1 ) { var marker = new google . maps . Marker ( { map : map , position : results [ 0 ] . geometry . location , icon : "https://img.icons8.com/color/48/000000/restaurant-.png" , Title : "" + i , } ) ; markerFunctionality ( marker , 0 ) ; markers . push ( marker ) ; } } else if ( option == 2 ) { var marker = new google . maps . Marker ( { map : map , position : results [ 0 ] . geometry . location , icon : "https://img.icons8.com/nolan/64/star.png" , Title : "" + i , } ) ; markerFunctionality ( marker , 2 ) ; markers . push ( marker ) ; } else { if ( userMarker == null ) { userLocation = results [ 0 ] . geometry . location ; latitude = results [ 0 ] . geometry . location . lat ( ) ; longitude = results [ 0 ] . geometry . location . lng ( ) ; converUserLocationToReadableAddressSetup ( ) ; userMarker = new google . maps . Marker ( { position : userLocation , map : map , icon : "https://img.icons8.com/ios-filled/50/000000/men-age-group-4.png" , } ) ; markerFunctionality ( userMarker , 1 ) ; } else { userLocation = results [ 0 ] . geometry . location ; latitude = results [ 0 ] . geometry . location . lat ( ) ; longitude = results [ 0 ] . geometry . location . lng ( ) ; converUserLocationToReadableAddressSetup ( ) ; userMarker . setPosition ( userLocation ) ; markerFunctionality ( userMarker , 1 ) ; deleteMarkers ( ) ; populateRestaurants ( ) ; } } } else { alert ( "Geocode was not successful for the following reason: " + status ) ; } } ) ; }
geocoder messes up with indexes so global var that represents index is needed
geocoder messes up with indexes so global var that represents index is needed
//if valid add the marker //restaurant //convert to string // add functionality for markers //favorite //convert to string // add functionality for markers //user markers //null marker //update user coords //use same marker and change marker position // have to update nearby restaurants, delete all markers then repopulate based on user location