diff options
Diffstat (limited to 'ishtar_common/static')
| -rw-r--r-- | ishtar_common/static/js/ishtar-map.js | 54 | 
1 files changed, 52 insertions, 2 deletions
| diff --git a/ishtar_common/static/js/ishtar-map.js b/ishtar_common/static/js/ishtar-map.js index ec11244a0..46a31c28e 100644 --- a/ishtar_common/static/js/ishtar-map.js +++ b/ishtar_common/static/js/ishtar-map.js @@ -42,6 +42,7 @@ var geoloc_activated = {};  var fetching_msg = "Fetching data...";  var base_maps_msg = "Base maps"; +var layers_msg = "Layers";  var _map_submit_search = function(query_vars, name, source, extra){      if (!extra) extra = "default"; @@ -236,9 +237,27 @@ var source_ign = function(options){      return new ol.layer.Tile(options);  } +var source_ign_cadastral = function(options){ +    options["source"] = new ol.source.WMTS({ +        url: "https://data.geopf.fr/wmts", +        layer: "CADASTRALPARCELS.PARCELLAIRE_EXPRESS", +        matrixSet: "PM", +        format: "image/png", +        style: "normal", +        tileGrid : new ol.tilegrid.WMTS({ +            origin: [-20037508,20037508], // topLeftCorner +            resolutions: ign_resolutions, // résolutions +            matrixIds: ["0","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15","16","17","18","19"] // ids des TileMatrix +        }) +    }); +    return new ol.layer.Tile(options); +} + +  var default_map_layers = {      'osm': source_osm, -    'ign': source_ign +    'ign': source_ign, +    'ign_cadastral': source_ign_cadastral  };  var get_layers = function(layers){ @@ -264,6 +283,26 @@ var get_layers = function(layers){      return ol_layers;  }; +var get_overlays = function(overlays){ +    if (!overlays){ +        overlays = [ +            { +                'type': 'ign_cadastral', +                'options': {'title': "IGN cadastre (France)", 'visible': false, "opacity": 0.5} +            } +        ]; +    } +    var ol_overlays = []; +    for (idx in overlays){ +        var layer_attr = overlays[idx]; +        ol_overlays.push( +            default_map_layers[layer_attr['type']](layer_attr['options']) +        ); +    } +    return ol_overlays; +} + +  /* styles */  var get_icon_style = function(feature){      return new ol.style.Style({ @@ -694,6 +733,17 @@ var initialize_base_map = function(map_id, layers){          })      ]; +    var overlays = get_overlays(); +    if (overlays){ +        map_layers[map_id].push( +            new ol.layer.Group({ +                title: layers_msg, +                visible: true, +                layers: overlays +            }) +        ); +    } +      // console.log(map_id);      map_view[map_id] = new ol.View({          projection: view_projection, @@ -981,4 +1031,4 @@ var update_all_map_display = function(){      for (idx in map){          map[idx].updateSize()      } -}
\ No newline at end of file +} | 
