Guía Digital [OSM y carga de un kml]
by deivil79
HTML
<script src="http://mapea4-sigc.juntadeandalucia.es/js/mapea.ol.min.js"></script>
<link rel="stylesheet" href="http://mapea4-sigc.juntadeandalucia.es/assets/css/mapea.ol.min.css">
<script src="http://mapea4-sigc.juntadeandalucia.es/js/configuration.js"></script>
<div id="map"></div>
CSS
html,
body,
#map {
padding: 0;
margin: 0;
width: 100%;
height: 100%;
}
JavaScript
let layerKML = new M.layer.KML({
url: "https://www.iaph.es/web/rutasc/23_rc_la_cal_andalucia_marruecos.kml",
name: "capaKML",
extract: true
});
var mapajs = M.map({
container: "map",
layers: [new M.layer.OSM()],
bbox: [96388, 3959795, 621889, 4299792],
controls: ["layerswitcher", "mouse"],
zoom: 4,
//projection: "EPSG:3857*m"
});
layerKML.on(M.evt.LOAD, function() {
console.log('Capa KML Cargada');
mapajs.setBbox(layerKML.getFeaturesExtent());
layerKML.getFeatures().forEach(function(feature){
console.log(feature.getGeometry());
})
});