CP-070-07

Panel StylePoint

by SIGC

HTML

<script src="https://sigc.desarrollo.guadaltel.es/mapea5/js/mapea.ol.min.js"></script>
<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea5/assets/css/mapea.ol.min.css">
<script src="https://sigc.desarrollo.guadaltel.es/mapea5/js/configuration.js"></script>
  <div class="row">
      <table id=tableStyle>
        <tr>
          <th onclick="ocultarTable('fill')">Fill</th>
        </tr>
        <tr>
          <td id="fill-td" class="display-hidden">
            <div class="input-group">
              <span class="label label-default">Color:</span>
              <input type="color" id="fill.color" onchange="set(this)">
            </div>
            <br>
            <div class="input-group">
              <span class="label label-default">Opacity:</span>
              <input type="range" id="fill.opacity" onchange="set(this)" value="0.5" min="0" max="1" step="0.1">
            </div>
          </td>
        </tr>
        <tr>
          <th onclick="ocultarTable('stroke')">Stroke</th>
        </tr>
        <tr>
          <td id="stroke-td" class="display-hidden">
            <div class="input-group">
              <span class="label label-default">Color:</span>
              <input type="color" id="stroke.color" onchange="set(this)">
            </div>
            <br>
            <div class="input-group">
              <span class="label label-default">width:</span>
              <input type="number" id="stroke.width" onchange="set(this)">
            </div>
            <br>
            <br>
            <div class="input-group">
              <span class="label label-default">linedash:</span>
              <input type="text" placeholder="10, 10" id="stroke.linedash" onchange="setArray(this)">
            </div>
            <br>
            <div class="input-group">
              <span class="label label-default">linedashoffset:</span>
              <input type="number" placeholder="60" id="stroke.linedashoffset" onchange="set(this)">
           ...

CSS

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


      body {
        margin: 0;
        padding: 0;
        height: 100%;
        overflow: auto;
      }

      #tableStyle {
        font-family: arial, sans-serif;
        border-collapse: collapse;
        width: 100%;
      }

      table#tableStyle td {
        border: 1px solid #dddddd;
        text-align: left;
        padding: 8px;
      }

      table#tableStyle th {
        border: 1px solid #dddddd;
        text-align: left;
        padding: 8px;
      }

      table#tableStyle tr:nth-child(even) {
        background-color: #dddddd;
      }

      input-group {
        margin: 20%;
      }

      .display-hidden {
        display: none;
      }

      .input-group {
        margin-bottom: 1em;
      }%;
        overflow: hidden;
      }

JavaScript

function ocultarTable(elementToManage) {
  let element = document.getElementById(elementToManage + "-td");
  if (element.classList.contains("display-hidden")) {
    element.classList.remove("display-hidden")
  }
  else {
    element.classList.add("display-hidden")
  }
}


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


let puntos = new M.layer.WFS({
  name: "Centros ASSDA - Subtipos",
  url: "https://clientes.guadaltel.es/desarrollo/geossigc/wfs?",
  namespace: "mapea",
  name: "centrosassda",
  legend: "centrosassda",
  geometry: 'POINT',
});

mapajs.addLayers([puntos]);

var stylePoint = new M.style.Point({
  'fill': {
    'color': '#fff',
    'opacity': 0.5,
  },
  'stroke': {
    'color': '#C8FE2E',
    'width': 15
  },
  'label': {
    'rotate': false,
    'font': 'bold italic 9px family',
    'scale': 1,
    'offset': [10, 20],
    'color': '#BCBCBC',
    'stroke': {
      'color': '#C8FE2E',
      'width': 15,
      'linedash': [1, 20],
      'linedashoffset': 60,
      'linecap': 'square',
      'linejoin': 'miter',
      'miterlimit': 15
    },
    'align': M.style.align.LEFT,
    'baseline': M.style.baseline.TOP,
    'text': 'Feature',
    'rotation': 0.05
  },
  'radius': 24,
  'icon': {
    'src': 'http://www.muycomputer.com/wp-content/uploads/2012/10/whatsapp-630x405.jpg',
    scale: 0.05
  }
});

FontSymbol = new M.style.Point({
  icon: {
    form: M.style.form.LOZENGE,
    gradient: true,
    class: "g-cartografia-alerta",
    fontsize: 0.5,
    radius: 8,
    rotation: 0,
    rotate: false,
    offset: [0, 0],
    color: 'red',
    fill: '#8A0829',
    gradientcolor: '#088A85'
  }
});

puntos.setStyle(stylePoint);

function set(element) {
  if (element.id[0] == "F") {
    let s = element.id.substring(11);
    if (s.includes("radius") || s.includes("rotation") ||...