Skip to content

Commit a7c8247

Browse files
committed
Bug fix
Fix bug where updating any option reset style.
1 parent 62fd4ac commit a7c8247

File tree

4 files changed

+91
-47
lines changed

4 files changed

+91
-47
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
**Bug fixes**
1414

1515
- Updated packages and build scripts to address `npm install` issues.
16+
- Fix issue where setting any option caused the button style to reset.
1617

1718
<a name="0.0.3"></a>
1819
# 0.0.3 (2025-04-04)

dist/azure-maps-geolocation-control.js

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,25 @@ MIT License
475475
b.setAttribute('alt', self._resource[0]);
476476
b.setAttribute('type', 'button');
477477
b.addEventListener('click', self._toggleBtn);
478+
if (self._hclStyle) {
479+
if (self._hclStyle === 'dark') {
480+
b.style.backgroundColor = self._darkColor;
481+
}
482+
}
483+
else {
484+
switch (self._options.style) {
485+
case 'dark':
486+
b.style.backgroundColor = self._darkColor;
487+
break;
488+
case 'auto':
489+
//Color will change between light and dark depending on map style.
490+
self._map.events.add('styledata', self._mapStyleChanged);
491+
b.style.backgroundColor = self._getColorFromMapStyle();
492+
break;
493+
//case 'light':
494+
//break;
495+
}
496+
}
478497
self._button = b;
479498
self._updateState();
480499
self.setOptions(self._options);
@@ -541,31 +560,33 @@ MIT License
541560
var self = this;
542561
var o = self._options;
543562
if (options) {
544-
var color = 'white';
545-
if (self._hclStyle) {
546-
if (self._hclStyle === 'dark') {
547-
color = self._darkColor;
548-
}
549-
}
550-
else {
551-
if (o.style === 'auto') {
552-
self._map.events.remove('styledata', self._mapStyleChanged);
553-
}
554-
o.style = options.style;
555-
switch (options.style) {
556-
case 'dark':
563+
if (options.style) {
564+
var color = 'white';
565+
if (self._hclStyle) {
566+
if (self._hclStyle === 'dark') {
557567
color = self._darkColor;
558-
break;
559-
case 'auto':
560-
//Color will change between light and dark depending on map style.
561-
self._map.events.add('styledata', self._mapStyleChanged);
562-
color = self._getColorFromMapStyle();
563-
break;
564-
//case 'light':
565-
//break;
568+
}
569+
}
570+
else {
571+
if (o.style === 'auto') {
572+
self._map.events.remove('styledata', self._mapStyleChanged);
573+
}
574+
o.style = options.style;
575+
switch (options.style) {
576+
case 'dark':
577+
color = self._darkColor;
578+
break;
579+
case 'auto':
580+
//Color will change between light and dark depending on map style.
581+
self._map.events.add('styledata', self._mapStyleChanged);
582+
color = self._getColorFromMapStyle();
583+
break;
584+
//case 'light':
585+
//break;
586+
}
566587
}
588+
self._button.style.backgroundColor = color;
567589
}
568-
self._button.style.backgroundColor = color;
569590
if (options.markerColor) {
570591
o.markerColor = options.markerColor;
571592
if (self._gpsMarker) {

0 commit comments

Comments
 (0)