[GeoJSON] - Test refresh
Test en mapea42_dev
by SIGC GUADALTEL
HTML
<script src="https://sigc.desarrollo.guadaltel.es/mapea/js/mapea.ol.min.js"></script>
<script src="https://sigc.desarrollo.guadaltel.es/mapea/js/configuration.js"></script>
<link rel="stylesheet" href="https://sigc.desarrollo.guadaltel.es/mapea/assets/css/mapea.ol.min.css">
<button type="button" name="button" onclick="addFeature()">Add Features</button>
<button onclick="setSource()">
set new source
</button>
<button type="button" name="button" onclick="refresh()">Refresh Layer</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 layer = new M.layer.GeoJSON({
crs: "4326",
name: 'points',
source: {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-6.207275390625,
38.06971703320484
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-5.6689453125,
38.013476231041935
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-5.5810546875,
37.243448378654115
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-4.89990234375,
37.44433544620035
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-6.2237548828125,
37.23032838760387
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [-6.520385742187499,
37.70120736474139
]
}
}
]
}
});
let feature = new M.Feature('feature_nueva', {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
218740.03278447635,
4239612.568478627
]
}
});
let feature2 = new M.Feature('feature_nueva2', {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [276160.7813963768, 4175203.8304147227]
}
})
//map.addLayers(layer);
const addFeature = () => layer.addFeatures([feature, feature2]);
const refresh...