Guest User

Untitled

a guest
Oct 31st, 2019
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const myModule = {
  2.     init: function() {
  3.             const self = this;
  4.             var coords = this.getCoords();
  5.            
  6.      
  7.             self.mymap = L.map('mapid').setView([lat, lng], 15);
  8.            
  9.             L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token=pk.eyJ1IjoibWFwYm94IiwiYSI6ImNpejY4NXVycTA2emYycXBndHRqcmZ3N3gifQ.rJcFIG214AriISLbB6B5aw', {
  10.                 maxZoom: 18,
  11.                 attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, ' +
  12.                     '<a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, ' +
  13.                     'Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
  14.                 id: 'mapbox.streets'
  15.             }).addTo(self.mymap);
  16.     },
  17.  
  18.     getCoords: function(){
  19.             navigator.geolocation.getCurrentPosition(function(position) {
  20.             let lat = position.coords.latitude;
  21.             let lng = position.coords.longitude;
  22.            
  23.  
  24.         });
  25.         console.log(lat);
  26.     },
  27.  
  28.     addMarker: function(){
  29.        
  30.         const marker = L.marker([lat, lng]).addTo(self.mymap);
  31.         mymap.removeLayer(marker)
  32.         console.log('test');
  33.     }
  34.  
  35.  
  36. };
  37.  
  38. window.onload = myModule.init();
  39.  
  40. //let timerId = setInterval(myModule.addMarker, 1000);
Advertisement
Add Comment
Please, Sign In to add comment