Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rbrundritt committed Oct 9, 2020
1 parent 4fcc0e8 commit eb49a6b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 24 deletions.
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,7 @@ Check out the [documentation](https://github.com/Azure-Samples/azure-maps-select

## Related Projects

**Open Azure Maps Web SDK modules**

* [Azure Maps Animation module](https://github.com/Azure-Samples/azure-maps-animations)
* [Azure Maps Geolocation Control module](https://github.com/Azure-Samples/azure-maps-geolocation-control)
* [Azure Maps Fullscreen Control module](https://github.com/Azure-Samples/azure-maps-fullscreen-control)
* [Azure Maps Sync Map module](https://github.com/Azure-Samples/azure-maps-sync-maps)
* [Azure Maps Services UI module](https://github.com/Azure-Samples/azure-maps-services-ui)

**Additional projects**

* [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.
* [Azure Maps Web SDK Samples](https://github.com/Azure-Samples/AzureMapsCodeSamples)
* [Azure Maps Gov Cloud Web SDK Samples](https://github.com/Azure-Samples/AzureMapsGovCloudCodeSamples)
* [Azure Maps & Azure Active Directory Samples](https://github.com/Azure-Samples/Azure-Maps-AzureAD-Samples)
Expand Down
4 changes: 2 additions & 2 deletions src/extensions/EventManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ declare module "azure-maps-control" {
* @param target The class to add the event for.
* @param callback The event handler callback.
*/
add(eventType: "dataselected", target: SelectionControl, callback: (e: SelectionControlEvents) => void): void;
add(eventType: "dataselected", target: SelectionControl, callback: (e: azmaps.Shape[]) => void): void;

/**
* Adds an event to a class once.
* @param eventType The event name.
* @param target The class to add the event for.
* @param callback The event handler callback.
*/
addOnce(eventType: "dataselected", target: SelectionControl, callback: (e: SelectionControlEvents) => void): void;
addOnce(eventType: "dataselected", target: SelectionControl, callback: (e: azmaps.Shape[]) => void): void;

/**
* Adds an event to a class.
Expand Down
38 changes: 28 additions & 10 deletions src/helpers/ControlStyler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Utils } from '../helpers/Utils';

/** A class that manages the style of a control. Add's 'light' or 'dark' as a CSS class to the container. */
export class ControlStyler {
/****************************
/****************************
* Private Properties
***************************/

Expand All @@ -24,15 +24,7 @@ export class ControlStyler {
constructor(container: HTMLElement, map: azmaps.Map, style: string) {
this._container = container;
this._map = map;
this._style = style;

// Set the style or add the auto listener.
if (style.toLowerCase() === azmaps.ControlStyle.auto) {
this._onStyleChange();
this._map.events.add('styledata', this._onStyleChange);
} else {
container.classList.add(style);
}
this.setStyle(style);
}

/****************************
Expand Down Expand Up @@ -69,6 +61,32 @@ export class ControlStyler {
}
}

/**
* Sets the style.
* @param style The new style.
*/
public setStyle(style: string) {
const self = this;

if(style !== self._style){
self._container.classList.remove(style);

if(self._style === azmaps.ControlStyle.auto){
self._map.events.remove('styledata', self._onStyleChange);
}

// Set the style or add the auto listener.
if (style.toLowerCase() === azmaps.ControlStyle.auto) {
self._onStyleChange();
self._map.events.add('styledata', self._onStyleChange);
} else {
self._container.classList.add(style);
}

self._style = style;
}
}

/****************************
* Private Methods
***************************/
Expand Down
4 changes: 2 additions & 2 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,15 +271,15 @@ declare module "azure-maps-control" {
* @param target The class to add the event for.
* @param callback The event handler callback.
*/
add(eventType: "dataselected", target: atlas.control.SelectionControl, callback: (e: atlas.control.SelectionControlEvents) => void): void;
add(eventType: "dataselected", target: atlas.control.SelectionControl, callback: (e: azmaps.Shape[]) => void): void;

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

/**
* Adds an event to a class.
Expand Down

0 comments on commit eb49a6b

Please sign in to comment.