Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const myModule = {
- init: function() {
- const self = this;
- var coords = this.getCoords();
- self.mymap = L.map('mapid').setView([lat, lng], 15);
- L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
- maxZoom: 18,
- attribution: 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
- '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
- 'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
- id: 'mapbox.streets'
- }).addTo(self.mymap);
- },
- getCoords: function(){
- navigator.geolocation.getCurrentPosition(function(position) {
- let lat = position.coords.latitude;
- let lng = position.coords.longitude;
- });
- console.log(lat);
- },
- addMarker: function(){
- const marker = L.marker([lat, lng]).addTo(self.mymap);
- mymap.removeLayer(marker)
- console.log('test');
- }
- };
- window.onload = myModule.init();
- //let timerId = setInterval(myModule.addMarker, 1000);
Advertisement
Add Comment
Please, Sign In to add comment