-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (30 loc) · 912 Bytes
/
Copy pathscript.js
File metadata and controls
37 lines (30 loc) · 912 Bytes
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
mapboxgl.accessToken = 'pk.eyJ1Ijoib25nenoiLCJhIjoiY2trdDNldXAwMGtsbzJ1cGk0dGJzYnJibyJ9.Dp3Woc0ws3NCWUmR_qIpyg';
function getLocation(){
function success(position) {
const latitude = position.coords.latitude;
const longitude = position.coords.longitude;
// if finish then chat type woohoo
var map = new mapboxgl.Map({
style: 'mapbox://styles/mapbox/light-v10',
center: [longitude, latitude],
zoom: 9,
pitch: 45,
bearing: -17.6,
container: 'map',
antialias: true
});
var marker = new mapboxgl.Marker({
color: "#FF0000",
draggable: true
}).setLngLat([longitude, latitude])
.addTo(map);
}
function error(e) {
console.log(e.message)
}
if('geolocation' in navigator){
navigator.geolocation.getCurrentPosition(success, error);
} else {
alert('Geolocation is not supported by your browser');
}
}