Leaflet Géoportail Ext : ReverseGeocode Control
Utilisation de L.geoportalControl.ReverseGeocode
by Géoportail IGNF
HTML
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script>
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css">
<script src="https://ignf.github.io/geoportal-extensions/leaflet-latest/dist/GpPluginLeaflet.js"></script>
<link rel="stylesheet" href="https://ignf.github.io/geoportal-extensions/leaflet-latest/dist/GpPluginLeaflet.css">
<div id="map"></div>
<div id="info"></div>
CSS
#map {
padding: 5px;
width: 100%;
height: 500px;
box-shadow: 0 0 10px #999;
}
#info {
padding: 5px;
width: 100%;
height: 20px;
font-family: monospace;
}
JavaScript
function go() {
map = L.map("map").setView([47, 2.424], 12);
var lyrMaps = L.geoportalLayer.WMTS({
layer: "GEOGRAPHICALGRIDSYSTEMS.PLANIGNV2",
}, { // leafletParams
opacity: 0.7
});
map.addLayer(lyrMaps);
var revCtrl = L.geoportalControl.ReverseGeocode({
collapsed : false,
resources : ["StreetAddress", "PositionOfInterest","CadastralParcel"],
delimitations : ["Point", "Circle","Extent"],
reverseGeocodeOptions : {}
});
map.addControl(revCtrl);
}
Gp.Services.getConfig({
apiKey: "essentiels",
onSuccess: go
});
var infoDiv = document.getElementById("info");
infoDiv.innerHTML = "<p> Extension Leaflet version " + Gp.leafletExtVersion + " (" + Gp.leafletExtDate + ")</p>";