Skip to content

Commit

Permalink
feat(map): map is now pitchable, compass to reset pitch
Browse files Browse the repository at this point in the history
  • Loading branch information
azarz committed Dec 3, 2024
1 parent e9688fe commit f72b69f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ function app() {
attributionControl: false,
maxZoom: 21,
locale: "fr",
maxPitch: 0,
touchPitch: false,
maxPitch: 45,
crossSourceCollisions: false,
});

Expand Down
2 changes: 1 addition & 1 deletion src/js/map-buttons-listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const addListeners = () => {
if (map.getBearing() === 0) {
DOM.$compassBtn.classList.add("d-none");
}
map.rotateTo(0);
map.easeTo({bearing: 0, pitch: 0});
}
});

Expand Down
12 changes: 1 addition & 11 deletions src/js/services/location.js
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const moveTo = (coords, zoom = Globals.map.getZoom(), panTo = true, gps = true)
if (panTo) {
if (tracking_active) {
let bearing = Globals.map.getBearing();
let pitch = 0;
let pitch = Globals.map.getPitch();
let padding = 0;
if (navigation_active) {
bearing = -mapBearing;
Expand All @@ -250,7 +250,6 @@ const moveTo = (coords, zoom = Globals.map.getZoom(), panTo = true, gps = true)
Globals.map.flyTo({
center: [coords.lon, coords.lat],
zoom: zoom,
pitch: 0
});
}
}
Expand Down Expand Up @@ -430,7 +429,6 @@ const locationOnOff = async () => {
}
DOM.$geolocateBtn.style.backgroundImage = "url(\"" + LocationFollowImg + "\")";
navigation_active = true;
Globals.map.setMaxPitch(45);
const padding = {top: DOM.$map.clientHeight * 0.5};
Globals.map.easeTo({
center: [currentPosition.coords.longitude, currentPosition.coords.latitude],
Expand All @@ -446,11 +444,6 @@ const locationOnOff = async () => {
position: "bottom"
});
} else {
Globals.map.flyTo({
pitch: 0,
duration: 500,
});
setTimeout( () => {Globals.map.setMaxPitch(0);}, 500);
DOM.$geolocateBtn.style.backgroundImage = "url(\"" + LocationImg + "\")";
tracking_active = false;
navigation_active = false;
Expand Down Expand Up @@ -550,7 +543,6 @@ const disableTracking = () => {
DOM.$geolocateBtn.style.backgroundImage = "url(\"" + LocationImg + "\")";
tracking_active = false;
if (navigation_active) {
Globals.map.setMaxPitch(0);
navigation_active = false;
}
Globals.map.touchZoomRotate.enable();
Expand All @@ -562,11 +554,9 @@ const disableNavigation = (bearing = Globals.map.getBearing()) => {
DOM.$geolocateBtn.style.backgroundImage = "url(\"" + LocationFixeImg + "\")";
navigation_active = false;
Globals.map.flyTo({
pitch: 0,
bearing: bearing,
duration: 500,
});
setTimeout( () => {Globals.map.setMaxPitch(0);}, 500);
if (bearing === 0) {
DOM.$compassBtn.classList.add("d-none");
}
Expand Down

0 comments on commit f72b69f

Please sign in to comment.