V4_2_0_MAPEA-Choropleth-Cluster-StyleCategory

Base para crear fiddles de mapea 4.2

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>
<div id="mapjs" class="container"></div>
<div id="pruebas" class="container">








      <button type="button" onclick="clusterf()">cluster</button>


      <button type="button" onclick="choroplethf()">choropleth</button>




      <button type="button" onclick="CategoryStylef()">CategoryStyle</button>


    </div>

CSS

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

JavaScript

let mapajs = M.map({

  container: "mapjs",

  projection: "EPSG:25830*m",

  layers: ["OSM"],



  controls: ['layerswitcher', 'overviewmap', 'mouse'],

});

let points = new M.layer.GeoJSON({

  name: "Empresas",

  url: "http://geostematicos-sigc.juntadeandalucia.es/geoserver/sepim/wfs?outputFormat=application/json&request=getfeature&typeNames=sepim:empresas&version=1.3.0",
  
  extract: false

});

points.on(M.evt.ADDED_LAYER, function() {

  alert("capa cargada");

});

mapajs.addLayers([points]);

var options = {
  ranges:

    [


    ],

  animated: true,

  hoverInteraction: true,

  displayAmount: true,

  selectedInteraction: true,

  distance: 80

};

var vendorParameters = {

  displayInLayerSwitcherHoverLayer: false,

  distanceSelectFeatures: 15

}

var style = new M.style.Cluster(options, vendorParameters);


let stylePoint = new M.style.Point({

  fill: {

    color: 'red'

  },

  radius: 5,

  icon: {

    src: 'https://cdn3.iconfinder.com/data/icons/free-icons-3/128/cat_6.png',

    rotation: 0.5,

    scale: 0.5,

    opacity: 0.8,

    anchor: [0.5, 1.9],

    anchororigin: 'top-left',

    anchororigin: 'top-left',

    anchorxunits: 'fraction',

    anchoryunits: 'fraction',



    rotate: false,

    // offset: [10, 0],

    crossorigin: null,

    snaptopixel: true,

    offsetorigin: 'bottom-left',

    size: [150, 95]

  }

});





let verde = new M.style.Point({
  fill: {
    color: 'green'
  },
  stroke: {
    color: 'green',
    width: 1
  },
  radius: 6
});
let amarillo = new M.style.Point({
  fill: {
    color: 'yellow'
  },
  stroke: {
    color: 'yellow',
    width: 1
  },
  radius: 3
});
let rojo = new M.style.Point({
  fill: {
    color: 'red'
  },
  stroke: {
    color: 'red',
    width: 1
  },
  radius: 6
});
let azul = new M.style.Point({
  fill: {
    color: 'blue'
  },
  stroke: {
    color: 'blue',
    width: 1
  },
  radius: 13
});
let categoryStyle = new M.style.Category("sector", {
  "Comercio": azul,
  "Industria":...