Skip to content

Commit eb49a6b

Browse files
committed
Minor updates
1 parent 4fcc0e8 commit eb49a6b

File tree

4 files changed

+33
-24
lines changed

4 files changed

+33
-24
lines changed

README.md

+1-10
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,7 @@ Check out the [documentation](https://github.com/Azure-Samples/azure-maps-select
5151

5252
## Related Projects
5353

54-
**Open Azure Maps Web SDK modules**
55-
56-
* [Azure Maps Animation module](https://github.com/Azure-Samples/azure-maps-animations)
57-
* [Azure Maps Geolocation Control module](https://github.com/Azure-Samples/azure-maps-geolocation-control)
58-
* [Azure Maps Fullscreen Control module](https://github.com/Azure-Samples/azure-maps-fullscreen-control)
59-
* [Azure Maps Sync Map module](https://github.com/Azure-Samples/azure-maps-sync-maps)
60-
* [Azure Maps Services UI module](https://github.com/Azure-Samples/azure-maps-services-ui)
61-
62-
**Additional projects**
63-
54+
* [Azure Maps Web SDK Open modules](https://github.com/microsoft/Maps/blob/master/AzureMaps.md#open-web-sdk-modules) - A collection of open source modules that extend the Azure Maps Web SDK.
6455
* [Azure Maps Web SDK Samples](https://github.com/Azure-Samples/AzureMapsCodeSamples)
6556
* [Azure Maps Gov Cloud Web SDK Samples](https://github.com/Azure-Samples/AzureMapsGovCloudCodeSamples)
6657
* [Azure Maps & Azure Active Directory Samples](https://github.com/Azure-Samples/Azure-Maps-AzureAD-Samples)

src/extensions/EventManager.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ declare module "azure-maps-control" {
2121
* @param target The class to add the event for.
2222
* @param callback The event handler callback.
2323
*/
24-
add(eventType: "dataselected", target: SelectionControl, callback: (e: SelectionControlEvents) => void): void;
24+
add(eventType: "dataselected", target: SelectionControl, callback: (e: azmaps.Shape[]) => void): void;
2525

2626
/**
2727
* Adds an event to a class once.
2828
* @param eventType The event name.
2929
* @param target The class to add the event for.
3030
* @param callback The event handler callback.
3131
*/
32-
addOnce(eventType: "dataselected", target: SelectionControl, callback: (e: SelectionControlEvents) => void): void;
32+
addOnce(eventType: "dataselected", target: SelectionControl, callback: (e: azmaps.Shape[]) => void): void;
3333

3434
/**
3535
* Adds an event to a class.

src/helpers/ControlStyler.ts

+28-10
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { Utils } from '../helpers/Utils';
33

44
/** A class that manages the style of a control. Add's 'light' or 'dark' as a CSS class to the container. */
55
export class ControlStyler {
6-
/****************************
6+
/****************************
77
* Private Properties
88
***************************/
99

@@ -24,15 +24,7 @@ export class ControlStyler {
2424
constructor(container: HTMLElement, map: azmaps.Map, style: string) {
2525
this._container = container;
2626
this._map = map;
27-
this._style = style;
28-
29-
// Set the style or add the auto listener.
30-
if (style.toLowerCase() === azmaps.ControlStyle.auto) {
31-
this._onStyleChange();
32-
this._map.events.add('styledata', this._onStyleChange);
33-
} else {
34-
container.classList.add(style);
35-
}
27+
this.setStyle(style);
3628
}
3729

3830
/****************************
@@ -69,6 +61,32 @@ export class ControlStyler {
6961
}
7062
}
7163

64+
/**
65+
* Sets the style.
66+
* @param style The new style.
67+
*/
68+
public setStyle(style: string) {
69+
const self = this;
70+
71+
if(style !== self._style){
72+
self._container.classList.remove(style);
73+
74+
if(self._style === azmaps.ControlStyle.auto){
75+
self._map.events.remove('styledata', self._onStyleChange);
76+
}
77+
78+
// Set the style or add the auto listener.
79+
if (style.toLowerCase() === azmaps.ControlStyle.auto) {
80+
self._onStyleChange();
81+
self._map.events.add('styledata', self._onStyleChange);
82+
} else {
83+
self._container.classList.add(style);
84+
}
85+
86+
self._style = style;
87+
}
88+
}
89+
7290
/****************************
7391
* Private Methods
7492
***************************/

typings/index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -271,15 +271,15 @@ declare module "azure-maps-control" {
271271
* @param target The class to add the event for.
272272
* @param callback The event handler callback.
273273
*/
274-
add(eventType: "dataselected", target: atlas.control.SelectionControl, callback: (e: atlas.control.SelectionControlEvents) => void): void;
274+
add(eventType: "dataselected", target: atlas.control.SelectionControl, callback: (e: azmaps.Shape[]) => void): void;
275275

276276
/**
277277
* Adds an event to a class once.
278278
* @param eventType The event name.
279279
* @param target The class to add the event for.
280280
* @param callback The event handler callback.
281281
*/
282-
addOnce(eventType: "dataselected", target: atlas.control.SelectionControl, callback: (e: atlas.control.SelectionControlEvents) => void): void;
282+
addOnce(eventType: "dataselected", target: atlas.control.SelectionControl, callback: (e: azmaps.Shape[]) => void): void;
283283

284284
/**
285285
* Adds an event to a class.

0 commit comments

Comments
 (0)