LOADING...

Preview

Pen ID
Unlock Campus Themeforest adv

 

Code

  
    Dog Parks In Seattle
    
    
    
    

  
  

    
    

Park search results

   
    
JS
var map;
var infowindow;

var data = [];

function initialize() {
  var seattle = new google.maps.LatLng(47.614848, -122.3359059);

  map = new google.maps.Map(document.getElementById('map-canvas'), {
    center: seattle,
    zoom: 9
  });

  var request = {
    location: seattle,
    radius: 50000,
    name: ['dog park']
  };
  infowindow = new google.maps.InfoWindow();
  var service = new google.maps.places.PlacesService(map);
  service.nearbySearch(request, callback);
}

function callback(results, status) {
  if (status == google.maps.places.PlacesServiceStatus.OK) {
    for (var i = 0; i < results.length; i++) {
      createMarker(results[i]);
      data.push(results[i]);
    }
   console.log(data);
    
   for (var i = 0; i < data.length; i++) {
      delete data[i]['icon'];
      delete data[i]['id'];
      delete data[i]['place_id'];
      delete data[i]['types'];
      delete data[i]['photos'];
      delete data[i]['opening_hours'];
      delete data[i]['scope'];
      delete data[i]['reference'];
      delete data[i]['html_attributions'];
    }
    
    var json = JSON.stringify(data, null, 2);
    
   $('.results').html(json);
  }
}

function createMarker(place) {
  var placeLoc = place.geometry.location;
  var marker = new google.maps.Marker({
    map: map,
    position: place.geometry.location
  });

  google.maps.event.addListener(marker, 'click', function() {
    infowindow.setContent(place.name);
    infowindow.open(map, this);
  });
}

google.maps.event.addDomListener(window, 'load', initialize);

Description

Mapping dog parks throughout the Seattle area via Google Maps
Term
Fri, 01/12/2018 - 16:46

Related Codes

Pen ID
Pen ID
Pen ID
Square Adv