Deprecate ol.DeviceOrientation
This commit is contained in:
@@ -31,6 +31,12 @@ tile.setLoader(function() {
|
|||||||
);
|
);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Deprecation of `ol.DeviceOrientation`
|
||||||
|
|
||||||
|
`ol.DeviceOrientation` is deprecated and will be removed in the next major version.
|
||||||
|
The device-orientation example has been updated to use the (gyronorm.js)[https://github.com/dorukeker/gyronorm.js] library.
|
||||||
|
|
||||||
|
|
||||||
### v4.3.0
|
### v4.3.0
|
||||||
|
|
||||||
#### `ol.source.VectorTile` no longer requires a `tileGrid` option
|
#### `ol.source.VectorTile` no longer requires a `tileGrid` option
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
"createMapboxStreetsV6Style": false,
|
"createMapboxStreetsV6Style": false,
|
||||||
"d3": false,
|
"d3": false,
|
||||||
"geojsonvt": false,
|
"geojsonvt": false,
|
||||||
|
"GyroNorm": false,
|
||||||
"jsPDF": false,
|
"jsPDF": false,
|
||||||
"jsts": false,
|
"jsts": false,
|
||||||
"saveAs": false,
|
"saveAs": false,
|
||||||
|
|||||||
@@ -4,16 +4,15 @@ title: Device Orientation
|
|||||||
shortdesc: Listen to DeviceOrientation events.
|
shortdesc: Listen to DeviceOrientation events.
|
||||||
docs: >
|
docs: >
|
||||||
This example shows how to track changes in device orientation.
|
This example shows how to track changes in device orientation.
|
||||||
tags: "orientation, openstreetmap"
|
[gyronorm.js](https://github.com/dorukeker/gyronorm.js) library is used to access and
|
||||||
|
normalize the events from the browser.
|
||||||
|
tags: "device, orientation, gyronorm"
|
||||||
|
resources:
|
||||||
|
- https://cdn.rawgit.com/dorukeker/gyronorm.js/v2.0.6/dist/gyronorm.complete.min.js
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
<label>
|
|
||||||
track changes
|
|
||||||
<input id="track" type="checkbox"/>
|
|
||||||
</label>
|
|
||||||
<p>
|
<p>
|
||||||
α : <code id="alpha"></code>
|
<div>α : <code id="alpha"></code></div>
|
||||||
β : <code id="beta"></code>
|
<div>β : <code id="beta"></code></div>
|
||||||
γ : <code id="gamma"></code>
|
<div>γ : <code id="gamma"></code></div>
|
||||||
heading : <code id="heading"></code>
|
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
goog.require('ol.DeviceOrientation');
|
// NOCOMPILE
|
||||||
goog.require('ol.Map');
|
goog.require('ol.Map');
|
||||||
goog.require('ol.View');
|
goog.require('ol.View');
|
||||||
goog.require('ol.control');
|
goog.require('ol.control');
|
||||||
goog.require('ol.layer.Tile');
|
goog.require('ol.layer.Tile');
|
||||||
|
goog.require('ol.math');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.OSM');
|
goog.require('ol.source.OSM');
|
||||||
|
|
||||||
@@ -28,32 +29,28 @@ var map = new ol.Map({
|
|||||||
view: view
|
view: view
|
||||||
});
|
});
|
||||||
|
|
||||||
var deviceOrientation = new ol.DeviceOrientation();
|
|
||||||
|
|
||||||
function el(id) {
|
function el(id) {
|
||||||
return document.getElementById(id);
|
return document.getElementById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
el('track').addEventListener('change', function() {
|
|
||||||
deviceOrientation.setTracking(this.checked);
|
|
||||||
});
|
|
||||||
|
|
||||||
deviceOrientation.on('change', function() {
|
var gn = new GyroNorm();
|
||||||
el('alpha').innerText = deviceOrientation.getAlpha() + ' [rad]';
|
|
||||||
el('beta').innerText = deviceOrientation.getBeta() + ' [rad]';
|
|
||||||
el('gamma').innerText = deviceOrientation.getGamma() + ' [rad]';
|
|
||||||
el('heading').innerText = deviceOrientation.getHeading() + ' [rad]';
|
|
||||||
});
|
|
||||||
|
|
||||||
// tilt the map
|
gn.init().then(function() {
|
||||||
deviceOrientation.on(['change:beta', 'change:gamma'], function(event) {
|
gn.start(function(event) {
|
||||||
var center = view.getCenter();
|
var center = view.getCenter();
|
||||||
var resolution = view.getResolution();
|
var resolution = view.getResolution();
|
||||||
var beta = event.target.getBeta() || 0;
|
var alpha = ol.math.toRadians(event.do.beta);
|
||||||
var gamma = event.target.getGamma() || 0;
|
var beta = ol.math.toRadians(event.do.beta);
|
||||||
|
var gamma = ol.math.toRadians(event.do.gamma);
|
||||||
|
|
||||||
|
el('alpha').innerText = alpha + ' [rad]';
|
||||||
|
el('beta').innerText = beta + ' [rad]';
|
||||||
|
el('gamma').innerText = gamma + ' [rad]';
|
||||||
|
|
||||||
center[0] -= resolution * gamma * 25;
|
center[0] -= resolution * gamma * 25;
|
||||||
center[1] += resolution * beta * 25;
|
center[1] += resolution * beta * 25;
|
||||||
|
|
||||||
view.setCenter(view.constrainCenter(center));
|
view.setCenter(view.constrainCenter(center));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ goog.require('ol.math');
|
|||||||
*
|
*
|
||||||
* @see {@link http://www.w3.org/TR/orientation-event/}
|
* @see {@link http://www.w3.org/TR/orientation-event/}
|
||||||
*
|
*
|
||||||
|
* @deprecated This class is deprecated and will removed in the next major release.
|
||||||
|
*
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.Object}
|
* @extends {ol.Object}
|
||||||
* @param {olx.DeviceOrientationOptions=} opt_options Options.
|
* @param {olx.DeviceOrientationOptions=} opt_options Options.
|
||||||
|
|||||||
Reference in New Issue
Block a user