|
|
|
//Load Map |
|
var map = L.map('map', { zoomControl:false, scrollWheelZoom: false }).setView([25.7617, -80.1], 8); |
|
//Mapbox Tile |
|
L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}', { |
|
attribution: 'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://mapbox.com">Mapbox</a>', |
|
maxZoom: 18, |
|
id: 'mapbox.outdoors', |
|
accessToken: 'pk.eyJ1IjoiYW50aGFtMjIiLCJhIjoiY2lxMnFzb254MDE2N2Zsbm9rMm9teTVpayJ9.kwXPfIma3_KhvJt_I9IDvg' |
|
}).addTo(map); |
|
|
|
//Markers |
|
//Miami |
|
var miami = L.marker([25.7617, -80.1918]).addTo(map).on('click', function () { |
|
$('.location').text("Miami"); |
|
$('.description').text("This is where I was born n raised!"); |
|
sidebar.show(); |
|
}); |
|
|
|
//Tallahassee |
|
var tallahassee = L.marker([30.4383, -84.2807]).addTo(map).on('click', function () { |
|
$('.location').text("Tallahassee"); |
|
$('.description').text("This is where I went to college!!"); |
|
sidebar.show(); |
|
}); |
|
|
|
//Havana |
|
var havana = L.marker([23.1136, -82.3666]).addTo(map).on('click', function () { |
|
|
|
$('.location').text("Havana"); |
|
$('.description').text("This is where my people are from!!!"); |
|
|
|
sidebar.show(); |
|
}); |
|
|
|
//Barcelona |
|
var barcelona = L.marker([41.3851, -2.1734]).addTo(map).on('click', function () { |
|
$('.location').text("Barcelona"); |
|
$('.description').text("This is one of my favorite cities!!"); |
|
sidebar.show(); |
|
}); |
|
|
|
|
|
|
|
//Sidebar Plugin |
|
var sidebar = L.control.sidebar('sidebar', { |
|
position: 'left' |
|
}); |
|
|
|
map.addControl(sidebar); |
|
|
|
setTimeout(function () { |
|
sidebar.show(); |
|
}, 500); |
|
|
|
// map.on('click', function () { |
|
// sidebar.hide(); |
|
// }); |
|
|
|
|
|
|
|
//LocationList Plugin |
|
var llist = L.control.locationlist({ locationsList : [ {title: 'Miami', latlng: [25.7617, -80.1], zoom: 8}, |
|
{title: 'Tallahassee', latlng: [30.4383, -84.2807], zoom: 8}, |
|
{title: 'Havana', latlng: [23.1136, -82.3666], zoom: 8}, |
|
{title: 'Barcelona', latlng: [41.3851, -2.1734], zoom: 8}], |
|
nextText : '->', |
|
nextTitle : 'Next', |
|
prevText : '<-', |
|
prevTitle : 'Previous', |
|
showList : false }); |
|
map.addControl(llist); |
|
|
|
|
|
//on next |
|
llist.on('next', function(event) { |
|
var currentLocation = event.target._currentLocation_index |
|
sidebar.hide(); |
|
if (currentLocation == 0) { |
|
$('.location').text("Miami"); |
|
$('.description').text("This is where I was born n raised!"); |
|
|
|
sidebar.show(); |
|
|
|
} else if (currentLocation == 1) { |
|
$('.location').text("Tallahassee"); |
|
$('.description').text("This is where I went to college!!"); |
|
sidebar.show(); |
|
} else if (currentLocation == 2) { |
|
$('.location').text("Havana"); |
|
$('.description').text("This is where my people are from!!!"); |
|
|
|
sidebar.show(); |
|
} else if (currentLocation == 3) { |
|
$('.location').text("Barcelona"); |
|
$('.description').text("This is one of my favorite cities!!"); |
|
sidebar.show(); |
|
} |
|
}); |
|
|
|
|
|
//on prev |
|
llist.on('prev', function(event) { |
|
var currentLocation = event.target._currentLocation_index |
|
sidebar.hide(); |
|
if (currentLocation == 0) { |
|
$('.location').text("Miami"); |
|
$('.description').text("This is where I was born n raised!"); |
|
sidebar.show(); |
|
} else if (currentLocation == 1) { |
|
$('.location').text("Tallahassee"); |
|
$('.description').text("This is where I went to college!!"); |
|
sidebar.show(); |
|
} else if (currentLocation == 2) { |
|
$('.location').text("Havana"); |
|
$('.description').text("This is where my people are from!!!"); |
|
|
|
sidebar.show(); |
|
} else if (currentLocation == 3) { |
|
$('.location').text("Barcelona"); |
|
$('.description').text("This is one of my favorite cities!!"); |
|
sidebar.show(); |
|
} |
|
}); |