All my js files now pass eslint tests
This commit is contained in:
parent
765a314a7d
commit
a27268bcbb
31 changed files with 39 additions and 37 deletions
44
public/build/assets/js/newplace-89a1be080e.js
Normal file
44
public/build/assets/js/newplace-89a1be080e.js
Normal file
|
@ -0,0 +1,44 @@
|
|||
/* global L */
|
||||
var button = document.querySelector('#locate');
|
||||
|
||||
if (button.addEventListener) {
|
||||
button.addEventListener('click', getLocation);
|
||||
} else {
|
||||
button.attachEvent('onclick', getLocation);
|
||||
}
|
||||
|
||||
function getLocation() {
|
||||
if ('geolocation' in navigator) {
|
||||
navigator.geolocation.getCurrentPosition(function(position) {
|
||||
updateForm(position.coords.latitude, position.coords.longitude);
|
||||
addMap(position.coords.latitude, position.coords.longitude);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function updateForm(latitude, longitude) {
|
||||
var inputLatitude = document.querySelector('#latitude');
|
||||
var inputLongitude = document.querySelector('#longitude');
|
||||
inputLatitude.value = latitude;
|
||||
inputLongitude.value = longitude;
|
||||
}
|
||||
|
||||
function addMap(latitude, longitude) {
|
||||
var form = document.querySelector('form');
|
||||
var div = document.createElement('div');
|
||||
div.setAttribute('id', 'map');
|
||||
form.appendChild(div);
|
||||
L.mapbox.accessToken = 'pk.eyJ1Ijoiam9ubnliYXJuZXMiLCJhIjoiVlpndW1EYyJ9.aP9fxAqLKh7lj0LpFh5k1w';
|
||||
var map = L.mapbox.map('map', 'jonnybarnes.gnoihnim')
|
||||
.setView([latitude, longitude], 15)
|
||||
.addLayer(L.mapbox.tileLayer('jonnybarnes.gnoihnim', {
|
||||
detectRetina: true
|
||||
}));
|
||||
var marker = L.marker([latitude, longitude], {
|
||||
draggable: true
|
||||
}).addTo(map);
|
||||
marker.on('dragend', function () {
|
||||
var markerLocation = marker.getLatLng();
|
||||
updateForm(markerLocation.lat, markerLocation.lng);
|
||||
});
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue