get position immediately.
This commit is contained in:
parent
27811515b4
commit
a9709d7a90
25
src/app.js
25
src/app.js
@ -2,21 +2,24 @@
|
|||||||
|
|
||||||
const $ = require('dollr/dollr').$;
|
const $ = require('dollr/dollr').$;
|
||||||
const L = require('leaflet');
|
const L = require('leaflet');
|
||||||
|
|
||||||
L.Icon.Default.imagePath = 'node_modules/leaflet/dist/images/';
|
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 © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
|
||||||
|
maxZoom: 18
|
||||||
|
}).addTo(Map);
|
||||||
|
|
||||||
|
|
||||||
$(function () {
|
$(function () {
|
||||||
console.log('loaded');
|
|
||||||
$('button').addEventListener('click', function () {
|
$('button').addEventListener('click', function () {
|
||||||
console.log('click');
|
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 © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="http://mapbox.com">Mapbox</a>',
|
|
||||||
maxZoom: 18
|
|
||||||
}).addTo(Map);
|
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user