Skip to content

Commit

Permalink
Fix style handling for WMTS/WMS layers
Browse files Browse the repository at this point in the history
  • Loading branch information
elias75015 committed Sep 24, 2019
1 parent 856ab8c commit 28d4577
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 4 additions & 2 deletions samples-src/pages/3d/page-modifyLayers-bundle.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ <h2>Carte 3D.</h2>
<div id="BoutonDiv">
<input type="button" name="export" onclick="modifyLayers();" value="modifiyLayers(null)"/><br/>
<input type="button" name="export" onclick="modifyLayers({'GEOGRAPHICALGRIDSYSTEMS.MAPS' : {opacity : 0.5}});" value="modifyLayers(GEOGRAPHICALGRIDSYSTEMS.MAPS)"/><br/>
<input type="button" name="export" onclick="modifyLayers({'ORTHOIMAGERY.ORTHOPHOTOS':{opacity : 0.2},'CADASTRALPARCELS.PARCELS':{visibility:false}});" value="modifyLayers(ORTHOIMAGERY.ORTHOPHOTOS,CADASTRALPARCELS.PARCELS)"/><br/>
<input type="button" name="export" onclick="modifyLayers({'ORTHOIMAGERY.ORTHOPHOTOS':{opacity : 0.2},'CADASTRALPARCELS.PARCELS':{style:'bdparcellaire_o'}});" value="modifyLayers(ORTHOIMAGERY.ORTHOPHOTOS,CADASTRALPARCELS.PARCELS)"/><br/>
</div>
{{/content}}

Expand All @@ -42,7 +42,9 @@ <h2>Carte 3D.</h2>
maxZoom : 15
},
"GEOGRAPHICALGRIDSYSTEMS.MAPS" : {},
"CADASTRALPARCELS.PARCELS" : {}
"CADASTRALPARCELS.PARCELS" : {
styleName : "bdparcellaire_o"
}
},
controlsOptions : {
layerSwitcher : {
Expand Down
12 changes: 12 additions & 0 deletions src/OpenLayers/OlMapLayers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,18 @@ OlMap.prototype._addGeoportalLayer = function (layerObj) {
if (layerOpts.hasOwnProperty("position")) {
olParams.zIndex = layerOpts.position;
}
// transmission du style demandé au LayerWMTS/LayerWMS
// WMTS : styleName (string)
if (layerOpts.hasOwnProperty("styleName")) {
olParams.sourceParams = {};
olParams.sourceParams.style = layerOpts.styleName;
}
// WMS : styleNames (array[string]) --> on prend le premier style spécifié
if (layerOpts.hasOwnProperty("styleNames")) {
olParams.sourceParams = {};
olParams.sourceParams.params = {};
olParams.sourceParams.params.STYLES = layerOpts.styleNames[0];
}
if (layerOpts.hasOwnProperty("minZoom") &&
layerOpts.minZoom >= 0 &&
layerOpts.minZoom <= 28) {
Expand Down

0 comments on commit 28d4577

Please sign in to comment.