IGNF / geoportal-extensions

French Geoportal Extensions for well-known javascript mapping libraries (Leaflet and OpenLayers)
https://ignf.github.io/geoportal-extensions/
Other
64 stars 33 forks source link

question: Parcelles cadastrales cliquables #366

Closed krabouilleur closed 8 months ago

krabouilleur commented 1 year ago

Bonjour,

est-ce qu'avec cette extension et leaflet on peut survoler afficher des parcelles cadastrales ET pouvoir cliquer dessus pour divers évènements ? un peu comme on peut le voir sur cadastre.gouv: https://cadastre.data.gouv.fr/map?style=ortho&parcelleId=383953670C0981#16.94/46.070484/5.036764

merci

elias75015 commented 1 year ago

Bonjour, les extensions Géoportail pour Leaflet ne proposent pas nativement un control de getFeatureInfo. Il faut passer par Leaflet directement.

En revanche les extensions Géoportail pour OpenLayers proposent un tel control.

Par exemple :

function go() {
    var photosLayer = new ol.layer.GeoportalWMTS({
        layer: "ORTHOIMAGERY.ORTHOPHOTOS"
    }) ;
    var parcelsLayer = new ol.layer.Tile({
        source : new ol.source.GeoportalWMS({
            layer: "CADASTRALPARCELS.PARCELLAIRE_EXPRESS"
        })
    }) ;
    var map = new ol.Map({
        target: 'map',
        layers: [
            photosLayer,
            parcelsLayer
        ],
        view: new ol.View({
            center: [288074.8449901076, 6247982.515792289],
            zoom: 15
        })
    });    

    var getFeatureInfo = new ol.control.GetFeatureInfo({
        layers : [
            {
                obj : parcelsLayer,
                infoFormat : "text/html",
            },
            {
                obj : photosLayer,
                infoFormat : "text/html",
            },
        ],
        options : {
            auto : true,
            active: true,
            defaultInfoFormat: "text/html",
            defaultEvent: "singleclick",
            cursorStyle: "pointer",
        }
    });
    map.addControl(getFeatureInfo);  
    var layerSwitcher = new ol.control.LayerSwitcher({});
    map.addControl(layerSwitcher);
}

Gp.Services.getConfig({
    apiKey: "essentiels",
    onSuccess: go
});

Ce qui donne au clic :

image