Skip to content

Commit

Permalink
Merge branch '137-fit-max-zoom-level-cause-map-flicker' into 'develop'
Browse files Browse the repository at this point in the history
Resolve "Fit max zoom level cause map flicker"

Closes #137

See merge request gtt/redmine_gtt!42
  • Loading branch information
sanak committed Jan 9, 2020
2 parents 1c4bc05 + d2c25ee commit 24e0bb9
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions assets/javascripts/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ var App = (function ($, publ) {
publ.setView = function () {

var view = new ol.View({
center: ol.proj.fromLonLat([defaults.lon, defaults.lat]),
// Avoid flicker (map move)
//center: ol.proj.fromLonLat([defaults.lon, defaults.lat]),
zoom: defaults.zoom,
maxZoom: defaults.maxzoom // applies for Mierune Tiles
});
Expand Down Expand Up @@ -469,12 +470,19 @@ var App = (function ($, publ) {
});
});
}
else if (geolocation) {
geolocation.once('change:position', function (error) {
maps.forEach(function (m) {
m.getView().setCenter(geolocation.getPosition());
});
else {
// Set default center, once
maps.forEach(function (m) {
m.getView().setCenter(ol.proj.transform([defaults.lon, defaults.lat],
'EPSG:4326', 'EPSG:3857'));
});
if (geolocation) {
geolocation.once('change:position', function (error) {
maps.forEach(function (m) {
m.getView().setCenter(geolocation.getPosition());
});
});
}
}
};

Expand Down

0 comments on commit 24e0bb9

Please sign in to comment.