Skip to content

Commit

Permalink
Adjusted orientations for iPhone.
Browse files Browse the repository at this point in the history
  • Loading branch information
Son-HNguyen committed Jun 30, 2017
1 parent c021d3b commit 6c69a13
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
.gitignore
data
*.gitignore
/nbproject/private/
16 changes: 9 additions & 7 deletions 3dwebclient/GPSController.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
function GPSController() {
this._liveTrackingActivated = false;
this._timer = undefined;
this._timerMiliseconds = 1000;
this._timerMiliseconds = 500;
this._savedAlpha = undefined;
this.createGPSButton();
}
Expand Down Expand Up @@ -96,7 +96,7 @@
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition, showError);
} else {
alert("Geolocation is not supported by this browser.");
CitydbUtil.showAlertWindow("OK", "Error", "Geolocation is not supported by this browser.");
}

function showPosition(position) {
Expand All @@ -105,12 +105,14 @@
function getLocation() {
if (window.DeviceOrientationEvent) {
window.addEventListener('deviceorientation', function auxOrientation(event) {
// one-time event
window.removeEventListener('deviceorientation', auxOrientation, false);
flyToLocationWithOrientation(position, event);
setTimeout(function () {
// one-time event
window.removeEventListener('deviceorientation', auxOrientation, false);
}, scope._timerMiliseconds);
}, false);
} else {
alert("Exact geolocation is not supported by this device.");
CitydbUtil.showAlertWindow("OK", "Error", "Exact geolocation is not supported by this device.");
flyToLocationWithOrientation(position, event);
}
}
Expand Down Expand Up @@ -169,10 +171,10 @@
scope._savedAlpha = oriAlpha;

cesiumCamera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(position.coords.longitude, position.coords.latitude, 2),
destination: Cesium.Cartesian3.fromDegrees(position.coords.longitude, position.coords.latitude, 150),
orientation: {
heading: oriAlpha,
pitch: oriBeta,
pitch: Cesium.Math.toRadians(-90),
roll: oriGamma
},
complete: function () {
Expand Down
2 changes: 1 addition & 1 deletion 3dwebclient/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<!-- GPS geolocation with device orientation in real-time -->
<script src="GPSController.js"></script>
<!-- Mobile utilities -->
<script type="text/javascript" src="Mobile.js"></script>
<script src="Mobile.js"></script>

<style>
@import url(../ThirdParty/Cesium/Widgets/widgets.css);
Expand Down

0 comments on commit 6c69a13

Please sign in to comment.