From a9709d7a90acea3ecea763665e145931d8129c71 Mon Sep 17 00:00:00 2001 From: Linus Miller Date: Thu, 14 Jul 2016 18:54:24 +0200 Subject: [PATCH] get position immediately. --- src/app.js | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/app.js b/src/app.js index 08934ca..ded4d85 100644 --- a/src/app.js +++ b/src/app.js @@ -2,21 +2,24 @@ const $ = require('dollr/dollr').$; const L = require('leaflet'); + L.Icon.Default.imagePath = 'node_modules/leaflet/dist/images/'; +const Map = L.map('map'); + +navigator.geolocation.getCurrentPosition((position) => { + console.log(); + Map.setView([position.coords.latitude, position.coords.longitude], 11); +}); + +L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox', + maxZoom: 18 +}).addTo(Map); + + $(function () { - console.log('loaded'); $('button').addEventListener('click', function () { console.log('click'); - navigator.geolocation.getCurrentPosition((position) => { - console.log(); - Map.setView([position.coords.latitude, position.coords.longitude], 11); - }); }); - - const Map = L.map('map'); - L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox', - maxZoom: 18 - }).addTo(Map); });