/** Script that contains shared functions and variables*/

// map object used in the route page
let map; 

/**
 * Uses placeId to retrieve details like coordinates, place name, etc.
 * @param {String} placeId a textual identifier that uniquely identifies a place
 * @return {Promise} result a Place Result object with fields name, geometry, id, etc.
 */
function findPlace(placeId, placesService) {
  const request = {
    placeId: placeId,
    fields: ['name', 'geometry', 'place_id', 'photos', 'formatted_address']
  }
  const result = new Promise((resolve, reject) => {
    placesService.getDetails(request, (result, status) => {
      if(status == "OK") {
        resolve(result);
      } else {
        alert("Status: " + status);
        reject(new Error("Could not retrieve place result object from request."));
      }
    })
  })

  return result;
}

/* exported findPlace, map*/

@@ -56,56 +56,8 @@
 */%0A%0A
-// map object used in the route page%0Alet map; %0A%0A
 /**%0A
@@ -830,12 +830,8 @@
 lace
-, map
+ 
 */%0A

remove map as a global var