If 64oz. to Freedom , Climb the Griffith , or the BrewTour are any indication, we are a drinking club with a hiking problem. Now you too can plan a brew march of your own. Just drag a brewery from the Breweries column to the Destinations column. Once you have more than one brewery in your Destinations list, the map find a route. You can drag and drop to reorder your list, or drag the breweries back to the left to remove them from the map.
This is a blatant copy of the Beer Crawl Calculator on PortlandBeer.org . If you guys want to have words over this, please let us know at @deathmarchla . Nothing but respect!!!
// Breweries Map
$('#brewery_crawl_map').gmap({'center': '34.107629,-118.571087', 'zoom': 11, 'disableDefaultUI':false, 'callback': function(map) {
var self = this;
[print_breweries js='1']
initialize_brewery_crawl_map();
calcRoute_brewery_crawl();
}});
$( "#sortable1, #sortable2" ).sortable({
connectWith: ".connectedSortable",
cursor: 'move',
tolerance: 'pointer',
stop: function(event, ui) {
calcRoute_brewery_crawl();
}
}).disableSelection();
$("#crawlurl").click(function(){
$(this).focus();
$(this).select();
});
var directionsDisplay;
var map;
function initialize_brewery_crawl_map() {
directionsDisplay = new google.maps.DirectionsRenderer();
var myOptions = {
mapTypeId: google.maps.MapTypeId.TERRAIN
}
map = new google.maps.Map(document.getElementById("brewery_crawl_map"), myOptions);
directionsDisplay.setMap(map);
}
function calcRoute_brewery_crawl() {
var points = [];
var waypoints = [];
var itemCount = 0;
var url = '';
$("#sortable2 li").each(function(){
url += $(this).html() + ",";
points[itemCount] = $(this).data('latlng');
itemCount++;
});
url = url.substr(0,url.length - 1)
url = url.replace(/ /g,'-');
if(itemCount >=2 ){
$("#sharecrawl").attr("href", "https://twitter.com/intent/tweet?text=Check out the custom Portland brewery crawl I created! http://www.portlandbeer.org/breweries/crawls/custom/" +url+ " %23craftbeer");
$("#sharecrawl").attr("title", "Share your custom Portland beer crawl!!");
$("#crawlurl").attr("value", "http://www.portlandbeer.org/breweries/crawls/custom/" +url);
} else {
$("#sharecrawl").attr("href", "#");
$("#sharecrawl").attr("title", "Add two destinations!");
$("#crawlurl").attr("value", "Add two destinations!");
}
if(itemCount == 1 || itemCount == 0){
} else {
if(itemCount == 2){
var start = points[0];
var end = points[1];
} else {
var start = points[0];
for(wp=1;wp