-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
have steps 1 and 2 complete for adding new rack
- Loading branch information
Showing
8 changed files
with
142 additions
and
16 deletions.
There are no files selected for viewing
This file was deleted.
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,19 @@ | ||
// define global map variables | ||
var map; | ||
var infoWindows = []; | ||
var brackMarkers = []; | ||
var currentCenter = []; | ||
|
||
$(document).ready(function(){ | ||
var path = window.location.pathname | ||
if (path === "/" || path === "/bracks") { | ||
geolocator() | ||
expandRackOptions() | ||
} else if (path === "/bracks/new") { | ||
url = '<%="https://maps.googleapis.com/maps/api/js?key=#{ENV['GOOGLE_MAP_KEY']}&libraries=places"%>' | ||
$.getScript(url).done(function() { | ||
var coords = {latitude: 39.7495666290001, longitude: -105.000145148} | ||
BrackMap.drawMapForNewBrack(coords) | ||
}) | ||
} | ||
}) |
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,85 @@ | ||
BrackMap.drawMapForNewBrack = function(coords) { | ||
// setup map instance vars for a central location | ||
brackMap = new BrackMap(coords) | ||
map = new google.maps.Map(document.getElementById('map'), { | ||
zoom: 10, | ||
center: brackMap.center | ||
}) | ||
var input = document.getElementById('pac-input') | ||
var searchBox = new google.maps.places.SearchBox(input); | ||
addNewBrackListener(searchBox) | ||
} | ||
|
||
function addNewBrackListener(searchBox) { | ||
searchBox.addListener('places_changed', function(){ | ||
var searched = false | ||
|
||
clearCurrentMarkers() | ||
// get location from search | ||
var places = searchBox.getPlaces(); | ||
if (places.length == 0) { return; } | ||
var place = places[0] | ||
if (!place.geometry) { | ||
console.log("Returned place contains no geometry"); | ||
return; | ||
} | ||
// place center marker | ||
var latLng = place.geometry.location | ||
brackMap = new BrackMap({latitude: latLng.lat(), longitude: latLng.lng()}) | ||
|
||
var userLatLng = new google.maps.LatLng(brackMap.lat, brackMap.lng); | ||
|
||
var userMarker = new google.maps.Marker({ | ||
position: userLatLng, | ||
map: map, | ||
animation: google.maps.Animation.DROP, | ||
icon: brackMap.image, | ||
draggable: true, | ||
title: "Drag me!" | ||
}) | ||
|
||
if (!searched) { | ||
moveToStepTwo() | ||
searched = true | ||
} | ||
|
||
currentCenter.push(userMarker) | ||
|
||
map.panTo(latLng) | ||
map.setZoom(18) | ||
// add marker drag listener | ||
google.maps.event.addListener(userMarker, 'dragend', function(event) { | ||
console.log(currentCenter[0].position.lat()) | ||
console.log(currentCenter[0].position.lng()) | ||
console.log('final position is '+event.latLng.lat()+' / '+event.latLng.lng()); | ||
}); | ||
|
||
}) | ||
} | ||
|
||
function moveToStepTwo() { | ||
setTimeout(function(){ | ||
$("h5").text("Drag bike rack pin to correct location on map") | ||
$("h5").fadeIn("slow", function() { | ||
$(this).toggleClass("highlight"); | ||
}); | ||
}, 1000) | ||
setTimeout(function(){ | ||
$("#map").animate({ | ||
height: "-=100" | ||
}, 700) | ||
$(".new-next").show() | ||
}, 2000) | ||
setTimeout(function () { | ||
$("h5").toggleClass("highlight"); | ||
$("h5").toggleClass("unhighlight"); | ||
}, 3000); | ||
$(".new-next").on('click', function(){ | ||
console.log("Yay!") | ||
debugger | ||
}) | ||
} | ||
|
||
function moveToStepThree() { | ||
|
||
} |
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
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 |
---|---|---|
@@ -1,6 +1,10 @@ | ||
class BracksController < ApplicationController | ||
before_action :authenticate_user, only: [:new] | ||
|
||
def index | ||
end | ||
|
||
def new | ||
end | ||
|
||
end |
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,11 @@ | ||
<h1>Add a New Rack</h1> | ||
|
||
<div class="map-box"> | ||
<h5>Input nearest address to new bike rack:</h5> | ||
<input id="pac-input" class="controls" type="text" placeholder="Search"> | ||
<hr> | ||
<div id="map"></div> | ||
<div tabindex="0" class="new-next"> | ||
<h3>Save Rack Location</h3> | ||
</div> | ||
</div> |
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
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