[GeoJSON] - setSource sin mapa

Test en mapea

by Javier G. Leal

HTML

<link rel="stylesheet" href="https://mapea4-sigc.juntadeandalucia.es/assets/css/mapea.ol.min.css">
<script src="https://sigc.desarrollo.guadaltel.es/mapea/js/mapea.ol.min.js"></script>
<script src="https://mapea4-sigc.juntadeandalucia.es/js/configuration.js"></script>
<button onclick="setSource()">
set new source
</button>
<button type="button" name="button" onclick="refresh()">Refresh Layer</button>
<button type="button" name="button" onclick="addLayer()">
Añadir capa
</button>
<div id="map" class="container"></div>

CSS

html,
 body {
   margin: 0;
   padding: 0;
   height: 100%;
   overflow: hidden;
 }

JavaScript

// map
let map = M.map({
  container: 'map',

  controls: []
});

let lyRuta = new M.layer.GeoJSON({
  name: "Ruta",
  extract: false
}, {
  style: new M.style.Line({
    stroke: {
      color: "{{color}}",
      width: 5
    }
  })
});


const refresh = () => lyRuta.refresh();
const addLayer = () => map.addLayers(lyRuta);
function setSource() {
  
    lyRuta.setSource({"type":"FeatureCollection","crs":{"type":"name","properties":{"name":"urn:ogc:def:crs:OGC:1.3:CRS84"}},"features":[{"type":"Feature","properties":{"name":"H.ARCOS","description":"PRUEBA GREA1","ts":"2015-04-29T07:05:32Z","order":0},"geometry":{"type":"Point","coordinates":[-5.64990699972222,37.1835019997222]}},{"type":"Feature","properties":{"name":"H.ARCOS","description":"PRUEBA GREA1","ts":"2015-04-29T10:05:32Z","order":1},"geometry":{"type":"Point","coordinates":[-5.94990699972222,37.1835019997222]}},{"type":"Feature","properties":{"name":"H.ARCOS","description":"PRUEBA GREA1","ts":"2015-04-29T11:05:32Z","order":2},"geometry":{"type":"Point","coordinates":[-6.02990699972222,37.1835019997222]}},{"type":"Feature","properties":{"name":"H.CAMAS","description":"PRUEBA 2","ts":"2015-04-29T08:59:33Z","order":0},"geometry":{"type":"Point","coordinates":[-5.5499256,37.1834471]}},{"type":"Feature","properties":{"name":"H.CAMAS","description":"PRUEBA 2","ts":"2015-04-29T09:59:33Z","order":1},"geometry":{"type":"Point","coordinates":[-5.9499256,37.1834471]}}]});
  
}