[Demo] feature inicial + addfeature
by Francisco
HTML
<script src="https://mapea4-sigc.juntadeandalucia.es/js/mapea-5.1.0.ol.min.js"></script>
<script src="http://mapea4-sigc.juntadeandalucia.es/js/configuration-5.1.0.js"></script>
<link rel="stylesheet" href="https://mapea4-sigc.juntadeandalucia.es/assets/css/mapea-5.1.0.ol.min.css">
<div id="map"></div>
CSS
html,
body,
#map {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
}
JavaScript
var mapajs = M.map({
container: "map",
controls: ["layerswitcher", "mouse"],
wmcfiles: ["mapa"]
});
// Añadimos la capa
let oficinas = new M.layer.GeoJSON({
name: "Oficinas",
source: {
"type": "FeatureCollection",
"features": [{
// "id": 2,
"properties": {
"nombre": 'Feature-1',
},
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [284469, 4142704]
}
}],
"crs": {
"properties": {
"name": "EPSG:25830"
},
"type": "name"
},
}});
mapajs.addLayers([oficinas]);
oficinas.on(M.evt.LOAD, () => {
let f2 = new M.Feature(2, {
properties: {
nombre: 'Feature-2'
},
type: "Feature",
id: 2,
geometry_name: "geometry",
geometry: {
type: "Point",
coordinates: [303597, 4159135]
}
})
oficinas.addFeatures([f2]);
});