forked from PnX-SI/GeoNature-atlas
-
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.
Merge branch 'add-layer-tree-control' into create_img_docker
- Loading branch information
Showing
12 changed files
with
148 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Gestionnaire de couches SIG additionnelles | ||
|
||
function createLeafletLayer(coucheSigInfo) { | ||
return L.tileLayer.wms( | ||
coucheSigInfo.url, | ||
coucheSigInfo.options | ||
); | ||
} | ||
|
||
function createEsriDynamicLayer(coucheSigInfo) { | ||
return L.esri.dynamicMapLayer( | ||
{ | ||
url: coucheSigInfo.url, | ||
layers: [] | ||
} | ||
); | ||
} | ||
|
||
function createLayer(coucheSigInfo) { | ||
if (coucheSigInfo.type === "wms") { | ||
return createLeafletLayer(coucheSigInfo); | ||
} else if (coucheSigInfo.type === "arcgisMapService") { | ||
return createEsriDynamicLayer(coucheSigInfo); | ||
} | ||
} | ||
|
||
function addLayerControlToMap(map) { | ||
var layer_types_map = { | ||
wms: "leaflet", | ||
arcgisMapService: "esriDynamic" | ||
}; | ||
var sigLayers = []; | ||
couchesSigInfo.forEach( | ||
(coucheSigInfo) => { | ||
sigLayers.push( | ||
{ | ||
layer: createLayer(coucheSigInfo), | ||
type: layer_types_map[coucheSigInfo.type], | ||
name: coucheSigInfo.name | ||
} | ||
); | ||
} | ||
); | ||
var layerTreeCtrl = new L.Control.LayerTreeControl(sigLayers, { | ||
position: 'topright', | ||
}); | ||
map.addControl(layerTreeCtrl); | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,15 @@ | ||
{% if config.COUCHES_SIG %} | ||
<script type="text/javascript"> | ||
var couchesSigInfo = {{ config.COUCHES_SIG|tojson }}; | ||
</script> | ||
{# TODO: further if on whether arcgis layers are present or not #} | ||
<script src="{{ url_for('static', filename='node_modules/esri-leaflet/dist/esri-leaflet.js') }}"></script> | ||
<link rel="stylesheet" | ||
href="{{ url_for('static', filename='node_modules/leaflet-layer-tree/src/L.LayerTreeControl.css') }}"/> | ||
<script src="{{ url_for('static', filename='node_modules/leaflet-layer-tree/src/L.LayerTreeControl.js') }}"></script> | ||
<script src="{{ url_for('static', filename='couchesSig.js') }}"></script> | ||
{% else %} | ||
<script type="text/javascript"> | ||
var couchesSigInfo = undefined; | ||
</script> | ||
{% endif %} |
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