Skip to content

Commit

Permalink
Mobile: Don't show loading if tracking is enabled, smarter tracking m…
Browse files Browse the repository at this point in the history
…ode (dont recenter map with every position update)
  • Loading branch information
uprel committed Jun 5, 2019
1 parent 49e8084 commit e9c8455
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions client_mobile/src/map.js
Expand Up @@ -63,9 +63,11 @@ Progress.prototype.update = function() {
* Show the progress.
*/
Progress.prototype.show = function(par) {
//do not show it over layer panel
if( $("#panelLayer").hasClass("ui-panel-open") === false ) {
$.mobile.loading('show', {textVisible: true, text: par, theme: 'c'});
//do not show it over layer panel and don't show it if location and following are on
if($("#panelLayer").hasClass("ui-panel-open") === false) {
if(Map.geolocation===null || !Map.geolocation.getTracking() || !Gui.following) {
$.mobile.loading('show', {textVisible: true, text: par, theme: 'c'});
}
}
};

Expand Down Expand Up @@ -889,8 +891,16 @@ Map.initialCenterOnLocation = function () {
};

Map.centerOnLocation = function() {
Map.map.getView().setCenter(Map.geolocation.getPosition());
Map.clampToScale(Config.map.minScaleDenom.geolocation);
//we do not recenter every position update
var center = Map.map.getView().getCenter();
var pos = Map.geolocation.getPosition();
var dx = Math.abs(center[0]-pos[0]);
var dy = Math.abs(center[1]-pos[1]);
var extent = Map.map.getView().calculateExtent();
if(dx > (ol.extent.getWidth(extent) / 4) || (dy > (ol.extent.getHeight(extent) / 4))) {
Map.map.getView().setCenter(pos);
Map.clampToScale(Config.map.minScaleDenom.geolocation);
}
};

Map.setWindowOrientation = function(orientation) {
Expand Down

0 comments on commit e9c8455

Please sign in to comment.