-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d2b6984
commit aec54cd
Showing
4 changed files
with
94 additions
and
11 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -11,15 +11,15 @@ function formatDepartementName(nom) { | |
} | ||
|
||
// Crée un élément h1 avec le nom du département | ||
const titre = html`<h1>Cartographie de ${formatDepartementName(departement)}</h1>`; | ||
const titre = html`<h1>Informations géographiques : ${formatDepartementName(departement)}</h1>`; | ||
|
||
display(titre); | ||
``` | ||
|
||
|
||
```js | ||
// Importation de Leaflet depuis npm pour gérer la carte | ||
//import * as L from "npm:leaflet"; | ||
import * as L from "npm:leaflet"; | ||
import * as d3 from "https://cdn.jsdelivr.net/npm/[email protected]/dist/d3.min.js"; | ||
import { calculateQuantiles, getColor, createStyle, onEachFeature, getWMSTileLayer,createGeoJsonLayer,updateLegend} from "../utils/fonctions.js"; | ||
import { quantileProbs, colorScales, departementConfig } from '../utils/config.js'; | ||
|
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,85 @@ | ||
<!-- ```js | ||
const name = view( | ||
Inputs.text({ | ||
label: "Name", | ||
placeholder: "Enter your name", | ||
value: "Anonymous" | ||
}) | ||
); | ||
``` | ||
```js | ||
name | ||
``` | ||
```js | ||
const search = view(Inputs.search(penguins, {placeholder: "Search penguins…"})); | ||
``` | ||
```js | ||
search | ||
``` | ||
```js | ||
name | ||
``` --> | ||
|
||
## leaflet | ||
|
||
|
||
```js | ||
const x = view( | ||
Inputs.text({ | ||
label: "Coordonnées", | ||
placeholder: "x ?", | ||
value: "-12.7808" | ||
}) | ||
); | ||
const y = view( | ||
Inputs.text({ | ||
label: "Coordonnées", | ||
placeholder: "y ?", | ||
value: "45.2276" | ||
}) | ||
); | ||
``` | ||
|
||
```js | ||
var center = [Number(x), Number(y)]; // Utilisation de Number() pour la conversion numérique | ||
``` | ||
```js | ||
import * as L from "npm:leaflet"; | ||
const mapDiv = display(document.createElement("div")); | ||
mapDiv.style = "height: 400px; width: 100%; margin: 0 auto;"; | ||
|
||
// Initialiser la carte avec la position centrale du département | ||
const map = L.map(mapDiv).setView(center, 14,10.4); | ||
|
||
// Ajout d'une couche de base OpenStreetMap | ||
const baseLayer = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { | ||
attribution: '© OpenStreetMap contributors', | ||
}); | ||
|
||
// Ajout d'une couche de base sombre pour le mode sombre | ||
const darkBaseLayer = L.tileLayer('https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png', { | ||
attribution: '© OpenStreetMap contributors © CartoDB', | ||
subdomains: 'abcd', | ||
maxZoom: 19, | ||
}); | ||
|
||
|
||
// Ajouter la couche de base par défaut | ||
baseLayer.addTo(map); | ||
|
||
// Définition des couches de base | ||
const baseLayers = { | ||
'Clair': baseLayer, | ||
'Sombre': darkBaseLayer, | ||
}; | ||
|
||
map; | ||
|
||
L.control.layers(baseLayers).addTo(map); | ||
|
||
|
||
`` |
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