-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajout de l'indicateur d'activité pour la plan IGN interactif et les c…
…ouches thématiques (#26) + mise à jour de la couche Plan IGN + héritage avec EventTarget des composants graphiques
- Loading branch information
1 parent
97d2112
commit aa5ac0d
Showing
11 changed files
with
4,592 additions
and
371 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import Globals from './globals'; | ||
import DOM from './dom'; | ||
|
||
/** | ||
* Indicateur d'activité du Plan IGN interactif et des couches thématiques sur la carte | ||
*/ | ||
class Interactivity { | ||
|
||
/** | ||
* constructeur | ||
* @param {*} map | ||
* @param {*} options | ||
*/ | ||
constructor(map, options) { | ||
this.options = options || { | ||
id: "PLAN.IGN.INTERACTIF$GEOPORTAIL:GPP:TMS" | ||
}; | ||
|
||
this.map = map; | ||
this.id = this.options.id || "PLAN.IGN.INTERACTIF$GEOPORTAIL:GPP:TMS"; // PII | ||
|
||
this.#listen(); | ||
|
||
this.pii = false; // couche PII chargée ? | ||
this.thematic = false; // couche thematic chargée ? | ||
this.position = false; // couche en position max ? | ||
|
||
return this; | ||
} | ||
|
||
/** | ||
* Ecouteurs sur : | ||
* - gestion des ajout / suppression / position des couches | ||
* - si zooms > 14 actif pour la couche PII | ||
* - la couche au dessus est elle un baseLayer ? | ||
*/ | ||
#listen() { | ||
this.onGetLastLayer = this.onGetLastLayer.bind(this); | ||
Globals.manager.addEventListener("addlayer", this.onGetLastLayer); | ||
Globals.manager.addEventListener("removelayer", this.onGetLastLayer); | ||
Globals.manager.addEventListener("movelayer", this.onGetLastLayer); | ||
|
||
this.map.on("zoom", (e) => { | ||
if (this.pii && this.position && Math.round(e.target.getZoom())>14) { | ||
this.active(); | ||
} else { | ||
(this.thematic && this.position) ? this.active() : this.disable(); | ||
} | ||
}); | ||
} | ||
|
||
/** | ||
* callback | ||
* @param {*} e | ||
* @private | ||
*/ | ||
onGetLastLayer(e) { | ||
var layer = e.detail.entries.pop(); | ||
this.thematic = this.pii = this.position = false; | ||
if (layer[0] === this.id) { | ||
this.pii = true; | ||
this.position = true; | ||
if (Math.round(this.map.getZoom())>14) { | ||
this.active(); | ||
} | ||
} else { | ||
if (layer[1].base) { | ||
this.disable(); | ||
} else { | ||
this.thematic = true; | ||
this.position = true; | ||
this.active(); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Active l'indicateur d'activité | ||
*/ | ||
active () { | ||
this.actived = true; | ||
DOM.$interactivityBtn.style["background-color"] = "white"; | ||
} | ||
|
||
/** | ||
* Desactive l'indicateur d'activité | ||
*/ | ||
disable () { | ||
this.actived = false; | ||
DOM.$interactivityBtn.style["background-color"] = "lightgray"; | ||
} | ||
|
||
} | ||
|
||
export default Interactivity; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.