-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (35 loc) · 1.53 KB
/
script.js
File metadata and controls
45 lines (35 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict';
// prettier-ignore
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
const form = document.querySelector('.form');
const containerWorkouts = document.querySelector('.workouts');
const inputType = document.querySelector('.form__input--type');
const inputDistance = document.querySelector('.form__input--distance');
const inputDuration = document.querySelector('.form__input--duration');
const inputCadence = document.querySelector('.form__input--cadence');
const inputElevation = document.querySelector('.form__input--elevation');
navigator.geolocation.getCurrentPosition(function(position) {
const { latitude } = position.coords;
const { longitude } = position.coords;
console.log(`https://www.google.com/maps/@${latitude},${longitude}`);
const coords =[latitude, longitude]
const map = L.map('map').setView(coords, 13);
L.tileLayer('https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
}).addTo(map);
map.on('click' , function(mapEvent) {
const {lat, lng} = mapEvent.latlng;
L.marker([lat, lng]).addTo(map)
.bindPopup(L.popup({
maxWidth: 250,
minWidth: 100,
autoClose: false,
closeOnClick: false,
className: 'running-popup'
}))
.setPopupContent('running')
.openPopup();
})
} , function() {
alert ('could not get the geo location')
});