Skip to content

Commit 632c407

Browse files
authored
Merge pull request #151 from Genymobile/dev/player-87-86-fix-altitude-autoset-and-position-slider-at-start
[PLAYER-87][PLAYER-86] fix issue post 4.2.0 (altitude autoset and slider component position at start)
2 parents 1d16ad7 + ebc734c commit 632c407

File tree

3 files changed

+23
-7
lines changed

3 files changed

+23
-7
lines changed

src/plugins/GPS.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ module.exports = class GPS extends OverlayPlugin {
565565
// Update map
566566
if (this.map) {
567567
this.clearMarkers();
568-
this.addMapMarker(position.coords.latitude, position.coords.longitude);
568+
this.addMapMarker(position.coords.latitude, position.coords.longitude, true);
569569
this.map.setCenter({lat: position.coords.latitude, lng: position.coords.longitude});
570570
}
571571
} catch (error) {
@@ -597,6 +597,8 @@ module.exports = class GPS extends OverlayPlugin {
597597
lng: info.longitude,
598598
},
599599
zoom: this.minimumZoomLevel,
600+
streetViewControl: false,
601+
mapTypeControl: false,
600602
});
601603

602604
// Add initial marker for selection from form
@@ -606,7 +608,7 @@ module.exports = class GPS extends OverlayPlugin {
606608
this.map.addListener('click', (event) => {
607609
this.clearMarkers();
608610
// Add new marker / capture coords for click location
609-
this.addMapMarker(event.latLng.lat(), event.latLng.lng());
611+
this.addMapMarker(event.latLng.lat(), event.latLng.lng(), true);
610612
});
611613
}
612614
}
@@ -616,8 +618,9 @@ module.exports = class GPS extends OverlayPlugin {
616618
*
617619
* @param {number} lat Latitude of the marker.
618620
* @param {number} lng Longitude of the marker.
621+
* @param {boolean} setAltitudeAuto Retrieve and set altitude from gmaps.
619622
*/
620-
addMapMarker(lat, lng) {
623+
addMapMarker(lat, lng, setAltitudeAuto=false) {
621624
if (typeof google === 'undefined') {
622625
return;
623626
}
@@ -646,7 +649,7 @@ module.exports = class GPS extends OverlayPlugin {
646649
}
647650

648651
// Get elevation if service is available
649-
if (this.elevationService) {
652+
if (this.elevationService && setAltitudeAuto) {
650653
const location = new google.maps.LatLng(numLat, numLng);
651654
this.elevationService.getElevationForLocations(
652655
{

src/plugins/util/components.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,18 @@ const slider = (() => {
112112

113113
// Update UI based on the current slider value
114114
const updateUI = () => {
115-
requestAnimationFrame(() => {
115+
requestAnimationFrame(async() => {
116+
// if CSS isn't ready cursorWidth & sliderWidth haven't size, so we loop to waiting CSS ready
117+
const start = performance.now();
118+
while (sliderCursor.offsetWidth === 0 || sliderDiv.offsetWidth === 0) {
119+
// After 10s we stop the loop
120+
if (performance.now() - start > 5000) {
121+
log.warn('Timeout: CSS not applied');
122+
break;
123+
}
124+
await new Promise((resolve) => setTimeout(resolve, 200));
125+
}
126+
116127
const val = parseFloat(input.value);
117128
const percentage = ((val - min) / (max - min)) * 100;
118129
const cursorWidth = sliderCursor.offsetWidth;
@@ -124,7 +135,7 @@ const slider = (() => {
124135
progressBar.style.width = `${percentage}%`;
125136
sliderCursor.style.left = adjustedPercentage;
126137

127-
const calc = ((percentage / 100) * 16 - 8) * -1;
138+
const calc = ((percentage / 100) * sliderCursor.offsetWidth - (sliderCursor.offsetWidth / 2)) * -1;
128139
sliderCursor.style.transform = `translate(${calc}px, -50%)`;
129140
});
130141
};

src/scss/components/_dropdown.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@
8787
}
8888

8989
.dropdown-item {
90-
padding: 16px 20px;
90+
height: 40px;
91+
max-height: 40px;
92+
padding: 4px 20px;
9193
cursor: pointer;
9294
display: flex;
9395
justify-content: space-between;

0 commit comments

Comments
 (0)