__ELIM__CP-070-03 StylePolygon

Estilos de poligonos para capas y features

by SIGC GUADALTEL

HTML

<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea42/assets/css/mapea.ol.min.css">
<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea42/plugins/geosearchbylocation/geosearchbylocation.min.css">
<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea42/plugins/wfstcontrols/wfstcontrols.min.css">
<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea42/plugins/geosearch/geosearch.min.css">
<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea42/plugins/printer/printer.min.css">
<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea42/plugins/measurebar/measurebar.min.css">
<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea42/plugins/streetview/streetview.min.css">
<script src="https://sigc.desarrollo.guadaltel.es/mapea42/vendor/browser-polyfill.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea42/js/mapea.ol.min.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea42/js/configuration.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea42/plugins/geosearchbylocation/geosearchbylocation.ol.min.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea42/plugins/wfstcontrols/wfstcontrols.ol.min.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea42/plugins/geosearch/geosearch.ol.min.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea42/plugins/printer/printer.ol.min.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea42/plugins/measurebar/measurebar.ol.min.js"></script>
Estilos por capa
    <button onclick="setStyleLayer(polygons, nullStylePolygon)">style polygon sin parametros</button>
    <button onclick="setStyleLayer(polygons, colorStylePolygon)">style polygon solo fill: color</button>
    <button onclick="setStyleLayer(polygons, strokeStylePolygon)">style polygon solo stroke: color</button>
    <br>
    <button...

CSS

<style rel="stylesheet">
      html,
      body {
        margin: 0;
        padding: 0;
        height: 100%;
        overflow: hidden;
      }

JavaScript

// constructor del mapa
let mapajs = M.map({
  container: "map",
  projection: "EPSG:4326*d",
  layers: ["OSM"],
  center: {
    x: -5.9584180843195425,
    y: 37.36912689160224
  },
  zoom: 5,
  controls: ['layerswitcher', 'overviewmap'],
});

let polygons = new M.layer.GeoJSON({
  name: 'polygons',
  source: {
    "type": "FeatureCollection",
    "features": [
      {
        "type": "Feature",
        "properties": {},
        "geometry": {
          "type": "Polygon",
          "coordinates": [
          [
            [
              -5.5810546875,
              40.713955826286046
            ],
            [
              -6.734619140625,
              40.153686857794035
            ],
            [
              -6.383056640625,
              39.78321267821705
            ],
            [
              -6.8994140625,
              39.47860556892209
            ],
            [
              -6.492919921875,
              39.39375459224348
            ],
            [
              -5.833740234375,
              39.38526381099774
            ],
            [
              -5.33935546875,
              39.78321267821705
            ],
            [
              -5.5810546875,
              40.713955826286046
            ]
          ]
        ]
        }
    },
      {
        "type": "Feature",
        "properties": {},
        "geometry": {
          "type": "Polygon",
          "coordinates": [
          [
            [
              -3.2080078125,
              40.6723059714534
            ],
            [
              -4.515380859375,
              41.12074559016745
            ],
            [
              -4.625244140625,
              40.01078714046552
            ],
            [
              -3.779296875,
              39.715638134796336
            ],
            [
              -4.603271484375,
              39.26628442213066
            ],
            [
              -4.4384765625,
              39.00211029922515
            ],
            [
 ...