Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
375 additions
and
368 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
export default ['$scope', 'hs.geolocation.service', 'hs.map.service', 'Core', function ($scope, service, OlMap, Core) { | ||
$scope.speed = null; | ||
$scope.alt = null; | ||
$scope.altitudeAccuracy = null; | ||
$scope.accuracy = null; | ||
$scope.Geolocation = service; | ||
|
||
if (Core.isMobile()) { | ||
$scope.switchGps = service.toggleGps; | ||
|
||
/** | ||
* Tracking info/starter, without argument return tracking status. With argument start tracking for mobile, with argument "True" start tracking for desktop | ||
* @memberof hs.geolocation.controller | ||
* @function gpsActive | ||
* @param {Boolean} set_to Optional argument | ||
*/ | ||
$scope.gpsActive = function (set_to) { | ||
if (arguments.length === 0) { | ||
return service.gpsStatus; | ||
console.log('arguments = 0'); | ||
} else { | ||
service.startGpsWatch(); | ||
console.log('Starting GPS.'); | ||
} | ||
}; | ||
} else { | ||
//Same as above, but for desktop version | ||
$scope.gpsActive = function (set_to) { | ||
if (arguments.length == 0) | ||
return service.geolocation.getTracking(); | ||
else { | ||
service.geolocation.setTracking(set_to); | ||
} | ||
}; | ||
} | ||
|
||
/** | ||
* Return which geolocation provider is currently used (Geolocation API / ol.Geolocation) | ||
* @memberof hs.geolocation.controller | ||
* @function getGeolocationProvider | ||
*/ | ||
$scope.getGeolocationProvider = function () { | ||
return service.geolocation; | ||
}; | ||
|
||
/** | ||
* State manager of following function. Without arguments returns following state in Boolean. With argument change following state. | ||
* @memberof hs.geolocation.controller | ||
* @function following | ||
* @param {Boolean} set_to Optional - Desired following state | ||
*/ | ||
$scope.following = function (set_to) { | ||
if (arguments.length == 0) | ||
return service.following; | ||
else { | ||
service.following = set_to; | ||
if (console) console.log(service.last_location); | ||
if (angular.isDefined(service.last_location)) { | ||
if (set_to) OlMap.map.getView().setCenter(service.last_location.latlng); | ||
if (Core.isMobile()) service.changed_handler(); | ||
} else { | ||
if (console) console.log('last location not defined'); | ||
} | ||
} | ||
}; | ||
|
||
/** | ||
* Change style of location layer | ||
* @memberof hs.geolocation.controller | ||
* @function setFeatureStyle | ||
* @param {ol.style.Style} style New style of location layer | ||
*/ | ||
$scope.setFeatureStyle = function (style) { | ||
return service.style = style; | ||
} | ||
|
||
$scope.$on('geolocation.updated', function (event) { | ||
$scope.speed = service.speed; | ||
$scope.alt = service.altitude; | ||
$scope.accuracy = service.accuracy; | ||
$scope.altitudeAccuracy = service.altitudeAccuracy; | ||
if (!$scope.$$phase) $scope.$digest(); | ||
}); | ||
|
||
$scope.$on('geolocation.switched', function (event) { | ||
service.gpsSwitch = service.gpsStatus ? 'Stop GPS' : 'Start GPS'; | ||
if (!$scope.$$phase) $scope.$digest(); | ||
}); | ||
|
||
$scope.$emit('scope_loaded', "Geolocation"); | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
export default ['hs.map.service', 'hs.geolocation.service', 'Core', 'config', function (OlMap, Geolocation, Core, config) { | ||
return { | ||
template: Core.isMobile() ? require('components/geolocation/partials/geolocation_cordova.html') : require('components/geolocation/partials/geolocation.html'), | ||
link: function link(scope, element, attrs) { | ||
if (!Core.puremapApp) { | ||
if (Core.isMobile()) { | ||
document.querySelector("#menu").appendChild(element[0]); | ||
} else { | ||
document.querySelector(".ol-overlaycontainer-stopevent").appendChild(element[0]); | ||
} | ||
} | ||
}, | ||
controller: ['$scope', function ($scope) { | ||
$scope.collapsed = true; | ||
$scope.blocateClick = function (e) { | ||
//Checking target is needed because follow button is inside locate button (container) | ||
//and because of that follow button triggers click on parent element | ||
if (!e.target.classList.contains('locateToggler')) return; | ||
$scope.collapsed = !$scope.collapsed; | ||
Geolocation.toggleFeatures(!$scope.collapsed); | ||
if (Core.isMobile()) { | ||
Geolocation.toggleGps(); | ||
} else { | ||
Geolocation.geolocation.setTracking(true); | ||
} | ||
} | ||
}], | ||
replace: true | ||
}; | ||
}] |
Oops, something went wrong.