43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
goog.require('ol.Geolocation');
|
|
goog.require('ol.Map');
|
|
goog.require('ol.View');
|
|
goog.require('ol.layer.Tile');
|
|
goog.require('ol.source.BingMaps');
|
|
|
|
|
|
var view = new ol.View({
|
|
center: [0, 0],
|
|
zoom: 2
|
|
});
|
|
|
|
var map = new ol.Map({
|
|
layers: [
|
|
new ol.layer.Tile({
|
|
source: new ol.source.BingMaps({
|
|
key: 'Ak-dzM4wZjSqTlzveKz5u0d4IQ4bRzVI309GxmkgSVr1ewS6iPSrOvOKhA-CJlm3',
|
|
imagerySet: 'Road'
|
|
})
|
|
})
|
|
],
|
|
renderer: exampleNS.getRendererFromQueryString(),
|
|
target: 'map',
|
|
view: view
|
|
});
|
|
|
|
var geolocation = new ol.Geolocation({
|
|
projection: view.getProjection(),
|
|
tracking: true
|
|
});
|
|
geolocation.once('change:position', function() {
|
|
view.setCenter(geolocation.getPosition());
|
|
view.setResolution(2.388657133911758);
|
|
});
|
|
|
|
// Use FastClick to eliminate the 300ms delay between a physical tap
|
|
// and the firing of a click event on mobile browsers.
|
|
// See http://updates.html5rocks.com/2013/12/300ms-tap-delay-gone-away
|
|
// for more information.
|
|
$(function() {
|
|
FastClick.attach(document.body);
|
|
});
|