-
Notifications
You must be signed in to change notification settings - Fork 883
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mike Wales
committed
Jun 27, 2016
1 parent
dca7567
commit e9b2596
Showing
13 changed files
with
4,838 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
581 changes: 581 additions & 0 deletions
581
Project_Code_11_FasterIsBetterPlacesAutocompletePart1.html
Large diffs are not rendered by default.
Oops, something went wrong.
727 changes: 727 additions & 0 deletions
727
Project_Code_12_FasterIsBetterPlacesAutocompletePart2.html
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
html, | ||
body { | ||
font-family: Arial, sans-serif; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#map { | ||
height: 100%; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="map"></div> | ||
<script> | ||
var map; | ||
function initMap() { | ||
// Constructor creates a new map - only center and zoom are required. | ||
map = new google.maps.Map(document.getElementById('map'), { | ||
center: {lat: 40.7413549, lng: -73.9980244}, | ||
zoom: 13 | ||
}); | ||
} | ||
</script> | ||
|
||
<script async defer | ||
src="https://maps.googleapis.com/maps/api/js?key=MYAPIKEY&v=3&callback=initMap"> | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
html, | ||
body { | ||
font-family: Arial, sans-serif; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#map { | ||
height: 100%; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="map"></div> | ||
<script> | ||
var map; | ||
function initMap() { | ||
// Constructor creates a new map - only center and zoom are required. | ||
map = new google.maps.Map(document.getElementById('map'), { | ||
center: {lat: 40.7413549, lng: -73.9980244}, | ||
zoom: 13 | ||
}); | ||
var tribeca = {lat: 40.719526, lng: -74.0089934}; | ||
var marker = new google.maps.Marker({ | ||
position: tribeca, | ||
map: map, | ||
title: 'First Marker!' | ||
}); | ||
} | ||
</script> | ||
|
||
<script async defer | ||
src="https://maps.googleapis.com/maps/api/js?key=MYAPIKEY&v=3&callback=initMap"> | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
html, | ||
body { | ||
font-family: Arial, sans-serif; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
#map { | ||
height: 100%; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="map"></div> | ||
<script> | ||
var map; | ||
|
||
// Create a new blank array for all the listing markers. | ||
var markers = []; | ||
|
||
function initMap() { | ||
// Constructor creates a new map - only center and zoom are required. | ||
map = new google.maps.Map(document.getElementById('map'), { | ||
center: {lat: 40.7413549, lng: -73.9980244}, | ||
zoom: 13 | ||
}); | ||
|
||
// These are the real estate listings that will be shown to the user. | ||
// Normally we'd have these in a database instead. | ||
var locations = [ | ||
{title: 'Park Ave Penthouse', location: {lat: 40.7713024, lng: -73.9632393}}, | ||
{title: 'Chelsea Loft', location: {lat: 40.7444883, lng: -73.9949465}}, | ||
{title: 'Union Square Open Floor Plan', location: {lat: 40.7347062, lng: -73.9895759}}, | ||
{title: 'East Village Hip Studio', location: {lat: 40.7281777, lng: -73.984377}}, | ||
{title: 'TriBeCa Artsy Bachelor Pad', location: {lat: 40.7195264, lng: -74.0089934}}, | ||
{title: 'Chinatown Homey Space', location: {lat: 40.7180628, lng: -73.9961237}} | ||
]; | ||
|
||
var largeInfowindow = new google.maps.InfoWindow(); | ||
var bounds = new google.maps.LatLngBounds(); | ||
|
||
// The following group uses the location array to create an array of markers on initialize. | ||
for (var i = 0; i < locations.length; i++) { | ||
// Get the position from the location array. | ||
var position = locations[i].location; | ||
var title = locations[i].title; | ||
// Create a marker per location, and put into markers array. | ||
var marker = new google.maps.Marker({ | ||
map: map, | ||
position: position, | ||
title: title, | ||
animation: google.maps.Animation.DROP, | ||
id: i | ||
}); | ||
// Push the marker to our array of markers. | ||
markers.push(marker); | ||
// Create an onclick event to open an infowindow at each marker. | ||
marker.addListener('click', function() { | ||
populateInfoWindow(this, largeInfowindow); | ||
}); | ||
bounds.extend(markers[i].position); | ||
} | ||
// Extend the boundaries of the map for each marker | ||
map.fitBounds(bounds); | ||
} | ||
|
||
// This function populates the infowindow when the marker is clicked. We'll only allow | ||
// one infowindow which will open at the marker that is clicked, and populate based | ||
// on that markers position. | ||
function populateInfoWindow(marker, infowindow) { | ||
// Check to make sure the infowindow is not already opened on this marker. | ||
if (infowindow.marker != marker) { | ||
infowindow.marker = marker; | ||
infowindow.setContent('<div>' + marker.title + '</div>'); | ||
infowindow.open(map, marker); | ||
// Make sure the marker property is cleared if the infowindow is closed. | ||
infowindow.addListener('closeclick',function(){ | ||
infowindow.setMarker(null); | ||
}); | ||
} | ||
} | ||
</script> | ||
|
||
<script async defer | ||
src="https://maps.googleapis.com/maps/api/js?key=MYAPIKEY&v=3&callback=initMap"> | ||
</script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<style> | ||
html, | ||
body { | ||
font-family: Arial, sans-serif; | ||
height: 100%; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.container { | ||
height: 100%; | ||
position: relative; | ||
} | ||
|
||
input { | ||
font-size: 12px; | ||
} | ||
|
||
h1 { | ||
color: #525454; | ||
font-size: 22px; | ||
margin: 0 0 10px 0; | ||
text-align: center; | ||
} | ||
|
||
#hide-listings, | ||
#show-listings { | ||
width: 48%; | ||
} | ||
|
||
#map { | ||
bottom:0px; | ||
height: 100%; | ||
left: 362px; | ||
position: absolute; | ||
right: 0px; | ||
} | ||
|
||
.options-box { | ||
background: #fff; | ||
border: 1px solid #999; | ||
border-radius: 3px; | ||
height: 100%; | ||
line-height: 35px; | ||
padding: 10px 10px 30px 10px; | ||
text-align: left; | ||
width: 340px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div class="options-box"> | ||
<h1>Find Your New NYC Home</h1> | ||
<div> | ||
<input id="show-listings" type="button" value="Show Listings"> | ||
<input id="hide-listings" type="button" value="Hide Listings"> | ||
</div> | ||
</div> | ||
<div id="map"></div> | ||
</div> | ||
<script> | ||
var map; | ||
|
||
// Create a new blank array for all the listing markers. | ||
var markers = []; | ||
|
||
function initMap() { | ||
// Constructor creates a new map - only center and zoom are required. | ||
map = new google.maps.Map(document.getElementById('map'), { | ||
center: {lat: 40.7413549, lng: -73.9980244}, | ||
zoom: 13, | ||
mapTypeControl: false | ||
}); | ||
|
||
// These are the real estate listings that will be shown to the user. | ||
// Normally we'd have these in a database instead. | ||
var locations = [ | ||
{title: 'Park Ave Penthouse', location: {lat: 40.7713024, lng: -73.9632393}}, | ||
{title: 'Chelsea Loft', location: {lat: 40.7444883, lng: -73.9949465}}, | ||
{title: 'Union Square Open Floor Plan', location: {lat: 40.7347062, lng: -73.9895759}}, | ||
{title: 'East Village Hip Studio', location: {lat: 40.7281777, lng: -73.984377}}, | ||
{title: 'TriBeCa Artsy Bachelor Pad', location: {lat: 40.7195264, lng: -74.0089934}}, | ||
{title: 'Chinatown Homey Space', location: {lat: 40.7180628, lng: -73.9961237}} | ||
]; | ||
|
||
var largeInfowindow = new google.maps.InfoWindow(); | ||
|
||
// The following group uses the location array to create an array of markers on initialize. | ||
for (var i = 0; i < locations.length; i++) { | ||
// Get the position from the location array. | ||
var position = locations[i].location; | ||
var title = locations[i].title; | ||
// Create a marker per location, and put into markers array. | ||
var marker = new google.maps.Marker({ | ||
position: position, | ||
title: title, | ||
animation: google.maps.Animation.DROP, | ||
id: i | ||
}); | ||
// Push the marker to our array of markers. | ||
markers.push(marker); | ||
// Create an onclick event to open an infowindow at each marker. | ||
marker.addListener('click', function() { | ||
populateInfoWindow(this, largeInfowindow); | ||
}); | ||
} | ||
document.getElementById('show-listings').addEventListener('click', showListings); | ||
document.getElementById('hide-listings').addEventListener('click', hideListings); | ||
} | ||
|
||
// This function populates the infowindow when the marker is clicked. We'll only allow | ||
// one infowindow which will open at the marker that is clicked, and populate based | ||
// on that markers position. | ||
function populateInfoWindow(marker, infowindow) { | ||
// Check to make sure the infowindow is not already opened on this marker. | ||
if (infowindow.marker != marker) { | ||
infowindow.marker = marker; | ||
infowindow.setContent('<div>' + marker.title + '</div>'); | ||
infowindow.open(map, marker); | ||
// Make sure the marker property is cleared if the infowindow is closed. | ||
infowindow.addListener('closeclick', function() { | ||
infowindow.marker = null; | ||
}); | ||
} | ||
} | ||
|
||
// This function will loop through the markers array and display them all. | ||
function showListings() { | ||
var bounds = new google.maps.LatLngBounds(); | ||
// Extend the boundaries of the map for each marker and display the marker | ||
for (var i = 0; i < markers.length; i++) { | ||
markers[i].setMap(map); | ||
bounds.extend(markers[i].position); | ||
} | ||
map.fitBounds(bounds); | ||
} | ||
|
||
// This function will loop through the listings and hide them all. | ||
function hideListings() { | ||
for (var i = 0; i < markers.length; i++) { | ||
markers[i].setMap(null); | ||
} | ||
} | ||
</script> | ||
|
||
<script async defer | ||
src= | ||
"https://maps.googleapis.com/maps/api/js?key=MYAPIKEY&v=3&callback=initMap"> | ||
</script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.