CP-CHAP-04 - Carga - Remove KML Layer
Carga y elimina capa KML
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 onclick="javascript:addKML()">
addKML
</button>
<button onclick="javascript:removeKML()">
removeKML
</button>
<button onclick="javascript:removeLayersKML()">
removeLayersKML (capaKML)
</button>
<button onclick="javascript:addWFS()">
addWFS
</button>
<button onclick="javascript:removeWFS()">
removeWFS
</button>
<button onclick="javascript:removeLayersWFS()">
removeLayersWFS
</button>
<button onclick="javascript:addWMS()">
addWMS
</button>
<button onclick="javascript:removeWMS()">
removeWMS
</button>
<button onclick="javascript:removeLayersWMS()">
removeLayersWMS (Redes)
</button>
<button onclick="javascript:addWMTS()">
addWMTS
</button>
<button onclick="javascript:removeWMTS()">
removeWMTS
</button>
<button onclick="javascript:removeLayersWMTS()">
removeLayersWMTS (Toporaster)
</button>
<div id="map"></div>
CSS
html,
body {
margin: 0;
padding: 0;
height: 100%;
overflow: hidden;
}
JavaScript
mapajs = M.map({
container: "map",
controls: ["layerswitcher", "mouse"],
wmcfile: ["callejero"],
layers: ["KML*Arboleda*http://mapea4-sigc.juntadeandalucia.es/files/kml/arbda_sing_se.kml*true"]
});
function addKML() {
//añadir la capa mediante objeto
mapajs.addKML(new M.layer.KML({
url: "http://mapea-sigc.juntadeandalucia.es/sepim_server/api/datos/kml/1193/item/341",
name: "capaKML",
extract: true
}));
//añadir la capa mediante cadena
//mapajs.addKML("KML*capaKML*http://mapea-sigc.juntadeandalucia.es/sepim_server/api/datos/kml/1194/item/469*true");
}
//removeKML
function removeKML() {
capasKML = mapajs.removeKML({
name: "capaKML"
});
}
//removeKML
function removeLayersKML() {
capasKML = mapajs.removeLayers({
name: "capaKML"
});
}
function addWFS() {
mapajs.addWFS(new M.layer.WFS({
url: 'http://clientes.guadaltel.es/desarrollo/geossigc/wfs?',
namespace: 'ggis',
name: 'Colegios',
geometry: 'POINT'
}));
}
//removeWFS
function removeWFS() {
capasKML = mapajs.removeWFS({
name: "Colegios"
});
}
//removeWFS
function removeLayersWFS() {
capasKML = mapajs.removeLayers({
name: "Colegios"
});
}
function addWMS() {
mapajs.addWMS(new M.layer.WMS({
'name': 'Redes_energeticas',
'legend': 'Redes',
'url': 'http://www.ideandalucia.es/wms/mta400v_2008?',
'transparent': true
}));
}
//removeWMS
function removeWMS() {
capasKML = mapajs.removeWMS({
name: "Redes_energeticas"
});
}
//removeWMS
function removeLayersWMS() {
capasKML = mapajs.removeLayers({
name: "Redes_energeticas"
});
}
function addWMTS() {
mapajs.addWMTS(new M.layer.WMTS({
url: 'http://www.ideandalucia.es/geowebcache/service/wmts?',
name: 'toporaster',
legend: 'toporaster',
}));
}
//removeWMS
function removeWMTS() {
capasKML = mapajs.removeWMTS({
name: "toporaster"
});
}
//removeWMS
function removeLayersWMTS() {
capasKML = mapajs.removeLayers({
name:...