getGeoJSON en fachada #204
Test en mapea 5
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">
<button id="button">
getGeoJSON
</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: []
});
const geojson = new M.layer.GeoJSON({
source: {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
-6.339111328124999,
37.87485339352928
],
[
-6.08642578125,
37.36142550190517
],
[
-5.756835937499999,
37.42252593456307
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
-6.427001953125,
36.721273880045004
],
[
-4.295654296875,
37.38761749978395
],
[
-4.28466796875,
36.97622678464096
]
]
}
},
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
-4.888916015625,
37.91820111976663
],
[
-3.3837890625,
36.79169061907076
],
[
-3.175048828125,
37.36142550190517
],
[
-4.119873046875,
37.96152331396614
]
]
}
}
]
},
name: "capa_json"
});
map.addLayers([geojson])
document.querySelector('#button').onclick = () => alert(map.getGeoJSON()[0].name)