showEnt.js 1.78 KB
function initMap() {
    // Try HTML5 geolocation.
    if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(function(position) {
            pos = {
                lat: position.coords.latitude,
                lng: position.coords.longitude
            };

            searchPlace('department_store','entertainment');
            searchPlace('movie_theater','entertainment');
            searchPlace('museum','entertainment');
            searchPlace('night_club','entertainment');
            searchPlace('shopping_mall','entertainment');
            searchPlace('zoo','entertainment');
        });
    }
}

function searchPlace(str, placeType) {
  switch(placeType) {
    case 'food':
      service.nearbySearch({
          location: pos,
          radius: 500,
          type: [str]
      }, callback_foods);
      break;
    case 'entertainment':
      service.nearbySearch({
          location: pos,
          radius: 500,
          type: [str]
      }, callback_entertainment);
      break;
    case 'room':
      service.nearbySearch({
          location: pos,
          radius: 500,
          type: [str]
      }, callback_rooms);
      break;
    default:
    break;
  }
}

function callback_entertainment(results, status) {
    if (status === google.maps.places.PlacesServiceStatus.OK) {
        for (var i = 0; i < results.length; i++) {
            result_entertainment.push(result[i])
        }
    }
}

  // const id = result['id'];
  // const place_id =result['place_id'];
  // const name = result['name'];
  // const address = result['vicinity'];
  // let category_big = category1
  // const category_small = result.types[0];
  // const image = "default"
  // const rating = result.rating;
  // const lng = result.geometry.viewport.ea.j;
  const lat =result.geometry.viewport.la.j;