Inicio
Descripción
Ejemplos
Consulta de propiedades
Actualizar mapa
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Documento HTML</title> <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css" integrity="sha256-p4NxAoJBhIIN+hmNHrzRCf9tD/miZyoHS5obTRR9BMY=" crossorigin=""/> <script src="https://unpkg.com/leaflet@1.9.4/dist/leaflet.js" integrity="sha256-20nQCchB9co0qIjJZRGuk2/Z9VM+kNiyxNV1lvTlZBo=" crossorigin=""></script> <script src="https://unpkg.com/leaflet.vectorgrid@latest/dist/Leaflet.VectorGrid.js"></script> <style> html, body { margin: 0; padding: 0; height: 100%; } .map { width: 100%; height: 100%; cursor: default; } #map { position: relative; z-index: 1; } #info { position: absolute; display: inline-block; height: auto; width: auto; z-index: 100; background-color: #333; color: #fff; text-align: center; border-radius: 4px; padding: 5px; left: 50%; transform: translateX(3%); visibility: hidden; pointer-events: none; } </style> </head> <body> <div id="info"></div> <div id="map" class="map"></div> <script> var map = L.map('map').setView([40.02, -4.9], 14); L.tileLayer('https://tms-ign-base.idee.es/1.0.0/IGNBaseTodo/{z}/{x}/{-y}.jpeg', { maxZoom: 17, attribution: "
CC BY 4.0 scne.es
" }).addTo(map); var layerUrl = "https://sigpac-hubcloud.es/mvt/recinto@3857@pbf/{z}/{x}/{y}.pbf"; var opciones = { minNativeZoom: 12, maxNativeZoom: 15 }; var vectorTileLayer = L.vectorGrid.protobuf(layerUrl, { vectorTileLayerStyles: { sliced: function(properties, zoom) { return { fillColor: 'blue', fillOpacity: 0.6, stroke: true, color: 'white', weight: 1 }; } }, interactive: true, getFeatureId: function(f) { return f.properties.id; } }).addTo(map); var info = document.getElementById('info'); var currentFeature; function displayFeatureInfo(latlng, properties) { info.style.left = latlng.x + 'px'; info.style.top = latlng.y + 'px'; info.style.visibility = 'visible'; info.innerText = "provincia: " + (properties.provincia || "") + "\n" + "municipio: " + (properties.municipio || "") + "\n" + "agregado: " + properties.agregado + "\n" + "zona: " + properties.zona + "\n" + "poligono: " + (properties.poligono || "") + "\n" + "parcela: " + (properties.parcela || "") + "\n" + "recinto: " + (properties.recinto || "") + "\n" + "superficie: " + (properties.superficie || "") + "\n" + "pendiente_media: " + (properties.pendiente_media || "") + "\n" + "altitud: " + (properties.altitud || "") + "\n" + "uso_sigpac: " + (properties.uso_sigpac || "") + "\n" + "subvencionabilidad: " + (properties.subvencionabilidad || "") + "\n" + "coef_regadio: " + (properties.coef_regadio || "") + "\n" + "incidencias: " + (properties.incidencias || "") + "\n" + "region: " + (properties.region || ""); } vectorTileLayer.on('mouseover', function(e) { var latlng = map.latLngToContainerPoint(e.latlng); var properties = e.layer.properties; displayFeatureInfo(latlng, properties); }); </script> </body> </html>