[Test- Mapea5] info en div

Demo ASSDA-CIPS. Filtros tipología - clúster

by SIGC

HTML

<script src="https://sigc.desarrollo.guadaltel.es/mapea5/js/mapea.ol.min.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea5/js/configuration.js"></script>
<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea5/assets/css/mapea.ol.min.css">
<div id="map">
  <div class="alert" id='alerta'>
    <span class="closebtn" onclick="this.parentElement.style.display='none';">&times;</span>
    <p id='info_centro'></p>
  </div>
</div>

CSS

html,
 body {
   margin: 0;
   padding: 0;
   height: 100%;
   overflow: hidden;
 }
 
 .div-info {
   position: fixed;
   bottom: inherit;
   left: initial;
   top: 0;
   right: 0;
   height: 200px;
   width: 50%;
   z-index: 9999;
 }
 
 .m-popup {
   position: fixed;
   bottom: inherit;
   left: initial;
   top: 0;
   right: 0;
   z-index: 9999;
 }
 
 .m-popup:before {
   border-top-color: initial;
   border-width: 0;
   left: inherit;
   margin-left: 0;
 }
 
 .m-popup:after,
 .m-popup:before {
   top: 0;
   border: inherit;
   content: " ";
   height: 0;
   width: 0;
   position: inherit;
   pointer-events: inherit;
 }
 
 .m-popup tr:nth-child(odd) {
   background-color: rgba(41, 105, 168, 0.78);
   color: white;
 }
 /*.tooltip {
   position: relative;
   padding: 3px;
   background: rgba(0, 0, 0, 0.9);
   color: white;
   opacity: 0.7;
   white-space: nowrap;
   font: 10pt sans-serif;
 }*/
 
 #categoria {
   background-color: rgba(55, 126, 235, 0.64);
   padding: 6px;
   border: 2px solid black;
 }
 
 /*.panel {
   display: none;
   padding: 10px;
   background-color: #f6f6f6;
   width: 200px;
   cursor: pointer;
 }
 
 .closePanel {
   display: none;
 }
 
 .openPanel {
   display: block;
   position: fixed;
   bottom: inherit;
   left: initial;
   top: 0;
   right: 0;
   z-index: 9999;
   border: 6px solid #5e8fb7;
 }*/
 
 .alert {
   padding: 20px;
   background-color: #EFF5FB;
   color: black;
   position: absolute;
   bottom: 0;
   left: 0;
   opacity: 0.8;
   z-index: 9999;
   overflow: auto;
   width: 50%;
   height: 50%;
   display: none;
   border-radius: 5px;
   box-shadow: 8px -8px 10px -4px rgba(0,0,0,.53);
   border: 1px solid #ccc;
 }
 
 .closebtn {
   margin-left: 15px;
   color: black;
   font-weight: bold;
   float: right;
   font-size: 22px;
   line-height: 20px;
   cursor: pointer;
   transition: 0.3s;
 }
 
 .closebtn:hover {
   color: black;
 }

JavaScript

var mapajs = M.map({
       'container': 'map',
       "controls": ["layerswitcher", "mouse", "scale", "overviewmap", "panzoombar", "scaleline", ],
       "wmcfile": ["cdau", "cdau_satelite"],
       "getfeatureinfo": "plain"
     });

     // Creamos la capa
     var centros = new M.layer.WFS({
       name: "Centros ASSDA",
       url: "https://clientes.guadaltel.es/desarrollo/geossigc/wfs?",
       namespace: "mapea",
       name: "centrosassda",
       legend: "centrosassda",
       getfeatureinfo: "plain",
       geometry: 'POINT',
       extract: true,
     });

     // Cuando se cargue la capa
     centros.on(M.evt.LOAD, function() {
       // Asignamos estilo de categorias
       centros.setStyle(categoryStyle);
       // Aplicamos cluster
       centros.setStyle(new M.style.Cluster(options, vendorParameters));
     });

     // Al seleccionar un centro, formamos una tabla con su info
     // y la mostramos
     centros.on(M.evt.SELECT_FEATURES, function(features, evt) {
       let feature = features[0];
       if (feature instanceof M.ClusteredFeature) {
         console.log('Es un cluster');
       } else {
         let fs = "<table width='100%'>";
         Object.keys(feature.getAttributes()).forEach(key => {
           if (feature.getAttribute(key) != "") {
             fs += `<tr><td>\t<b>${key}</b>: ${feature.getAttribute(key)}</tr></td>`;
           }
         });
         fs += '</table>';
         // Actualizamos contenido del div
         document.getElementById("info_centro").innerHTML = fs;
         document.getElementById("alerta").style.display = 'block';

       }
     });

     // Al deseleccionar un centro, ocultamos la info
     centros.on(M.evt.UNSELECT_FEATURES, function() {
       document.getElementById("alerta").style.display = 'none';
     });

     // Añadimos la capa al mapa
     mapajs.addLayers(centros);

     // CONFIGURACIÓN ESTILO CATEGORIAS
     let dia = new M.style.Point({
       icon: {
         src:...