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

// object that communicates with the GMaps API service
let directionsService;
 
// object that renders display results on the map
let directionsRenderer;

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

// object that communicates with the Places API service
let placesService;

/**
 * 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 object
 */
function findPlace(placeId) {
  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(error);
      }
    })
  }).catch(error => {
    alert("Error.Cannot process this request due to " + error);
  });

  return result;
}

/* exported findPlace */
/* global google */
@@ -60,282 +60,51 @@
 %0A// 
-object that communicates with the GMaps API service%0Alet directionsService;%0A %0A// object that renders display results on the map%0Alet directionsRenderer;%0A%0A// map object used in the route page%0Alet map; %0A%0A// object that communicates with the Places API service%0Alet placesService;
+map object used in the route page%0Alet map; 
 %0A%0A/*
@@ -686,21 +686,81 @@
  reject(
-error
+new Error(%22Could not retrieve place result object from request.%22)
 );%0A     
@@ -799,60 +799,16 @@
     
+  
 alert(
-%22Error.Cannot process this request due to %22 + 
 erro
@@ -863,27 +863,59 @@
 lace
- */%0A/* global googl
+, map, placesService */%0A/* global placesService:tru
 e */

change exports