dlr-eoc / ukis-frontend-libraries

A collection of angular ui-components, services, interfaces... to help you create geospatial mapping applications for the web.
Apache License 2.0
17 stars 4 forks source link

Harmonize popup properties #160

Closed boeckMt closed 1 year ago

boeckMt commented 1 year ago

Description

Currently (ukis: v10.1.0), layer popups are given different properties whether they are for raster or vector or they have Layer.dynamicPopup.

The user should get a harmonized object with properties for layer, feature and other stuff to visualize.

Relevant Package

This feature request is for @dlr-eoc/map-ol

Examples

raster: gets all properties from the ukis layer plus event and color

vector: gets all properties from the feature

dynamicPopup: gets all properties from the ukis layer plus event, feature, layer and dynamicPopup itself


properties from the ukis layer https://github.com/dlr-eoc/ukis-frontend-libraries/blob/v10.1.0/projects/map-ol/src/lib/map-ol.service.ts#L777

boeckMt commented 1 year ago

@voinSR, @MichaelLangbein and @lucas-angermann what do you think about this? I also think we can remove some properties from the ukis layer which are currently added.

extent: layer.bbox
filtertype: "layers"
id: "customLayerOlGroup_olUID:Layer_76"
map: `olMap`
maxResolution: Infinity
maxZoom: Infinity
minResolution: 0
minZoom: -Infinity
name: `ukis layer name`
opacity: 1
popup: `ukis popup`
preload: 0
source: `olLayerSource`
useInterimTilesOnError: true
visible: true
zIndex: 18

We could also remove most of them an if the user needs it get them with olMapSvc.getLayerByKey?

boeckMt commented 1 year ago

Possible properties to pass to prepareAddPopup()


interface IPopupProperties {
  layerId: string;
  layerName: string;
  mapEvent?: any;
  layer?: any;
  feature?: any;
  color?: Uint8ClampedArray | Uint8Array | Float32Array | DataView;
  /** properties of the feature/layer or asyncData */
  properties: any;
}
let properties: IPopupProperties = {};

...
// add layer and feature or color

We need a flat object so filter and rename work!

Some properties of the layer can be overwritten if they have the same name in the feature!


Also It would be a breaking change!!! if we remove the complete layer and event from raster

boeckMt commented 1 year ago

maplibre

Properties of queryRenderedFeatures

// layers: https://maplibre.org/maplibre-style-spec/layers/#layers
// Sources: https://maplibre.org/maplibre-style-spec/sources/#sources
{
    "geometry": {
      "type": "MultiPolygon",
      "coordinates":... 
    },
    "type": "Feature",
    "properties": any,
    "layer": layers
    "source": "openmaptiles",
    "sourceLayer": "water",
    "state": {}
}

Leaflet

Properties of layer.on(e: MouseEvent)

// layer
// feature
// properties

L.geoJson(data, {
    style: style,
    onEachFeature: (feature, layer)=>{
      layer.on({
         click: (e)=>{
           layer = e.target;
           feature = layer.feature;
           properties = layer.feature.properties;
         }
      });
   }
}).addTo(map);

map.eachLayer(layer => {
  layer.bindPopup(...);
})

/**
evt: {
  originalEvent: PointerEvent
  containerPoint: Object
  layerPoint: Object (x,y,...)
  latlng: Object 
  type: "click"
  target: NewClass (Map)
  sourceTarget: NewClass
 }
*/
map.on("click", (evt) => {
  evt.target.eachLayer((l) => {
    if (l.feature) {
      console.log(l.feature);
    } else if(l.getContainer) {
      console.log(l.getContainer());
    }
  });
});