Marc Jansen Andreas Hocevar
FOSSGIS 2022, Online-Event, 10.03.2022
            A high-performance, feature-packed library for all your mapping
            needs.
            
          
          2006: v2 + OSM = 1. freie Alternative zu Google Maps
2012-2014 v3: Komplettes Rewrite mit neuem API
2014-2017: Krise! Kein Upgradepfad von v2 auf v3
2017 v4: Wir gewinnen wieder Vertrauen und Nutzer
2022 v6.13: Wir sind immer noch da, aktiver denn je!
Welche Pixel haben sich geändert?
{
  color: [
    'case',
    ['==', ['band', 1], ['band', 2]],
    [0, 0, 0, 0], // equal
    [255, 165, 0, 0.8] // different
  ]
}Rohdaten abfragen
  const data = layer.getData(event.pixel);
  if (!data) {
    return;
  }
  const red = data[0];
  const nir = data[1];
  const ndvi = (nir - red) / (nir + red);Band Math - Rechnen mit RGB
// elevation = -10000 + ((R * 256 * 256 + G * 256 + B) * 0.1)
const elevation = [
  '+',
  -10000,
  ['*',
    ['+',
      ['*', 256 * 256, ['band', 1]],
      ['+', ['*', 256, ['band', 2]],
      ['band', 3]]
    ],
    0.1 * 255,
  ],
];Style Variablen
const style = {
  variables: {
    stauziel: 368,
  },
  color: [
    'case',
    ['<=', elevation, ['var', 'stauziel']],
    [139, 212, 255, 1],
    [139, 212, 255, 0],
  ],
}Aktualisierung nach User-Interaktion
slider.addEventListener('input', () => {
  layer.updateStyleVariables({
    stauziel: parseFloat(slider.value)
  });
});Schon mal in der Situation gewesen, für einen Layer je nach Zoom und Ausschnitt unterschiedliche Sources verwenden zu wollen?
const pyramid = new WebGLTileLayer({
  sources: sourcesFromTileGrid(
    tileGrid,
    ([z, x, y]) => new GeoTIFFSource({
      sources: [ { url: `./data/${z}/${y}/${x}.tif` } ],
    })
  ),
});Mapbox Vector Tiles + Mapbox Style
          (Mapbox, Maptiler, Geoapify, Carto, Esri, ...)
import MapboxVectorLayer from 'ol/layer/MapboxVector.js';
const layer = new MapboxVectorLayer({
  styleUrl: 'https://api.maptiler.com/maps/streets/style.json?key=' + key
});Beispiele für Performance-Optimierungen
Und was habe ich davon?
OpenLayers kann Karten beliebig umprojizieren.
          Auch Rasterlayer 💪
Aber brauche ich das?
Wahrscheinlich nicht!
import proj4 from "proj4";
import { register } from "ol/proj/proj4.js";
import { setUserProjection } from "ol/proj.js";
proj4.defs('EPSG:31259', '+proj=tmerc +lat_0=0 +lon_0=16.33333333333333 +k=1 +x_0=750000 +y_0=-5000000 +ellps=bessel +towgs84=577.326,90.129,463.919,5.137,1.474,5.297,2.4232 +units=m +no_defs');
register(proj4);
setUserProjection('EPSG:31259');Von nun an ist alles in MGI / Austria GK M34 🎉
          Nur die Karte bleibt in Web Mercator ✅
const map = L.map('map').setView([51.505, -0.09], 13);useGeographic();
const map = new Map({
  target: 'map',
  view: new View({ center: [-0.09, 51.505], zoom: 13 })
});L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  attribution: '© OpenStreetMap contributors'
}).addTo(map);map.addLayer(new TileLayer({ source: new OSM() }));const marker = L.marker([51.5, -0.09]);
marker.addTo(map);const marker = new Marker([-0.09, 51.5]);
marker.setMap(map);Marker: Andreas Hocevars 3d Party Library
ol-marker-feature
marker
  .bindPopup('A pretty CSS3 popup.
 Easily customizable.')
  .openPopup();const popup = new Popup({ offset: [0, -32] });
map.addOverlay(popup);
marker.on('click', () => popup.show(marker.getLocation(),
  'A pretty CSS3 popup.
 Easily customizable.'));
marker.dispatchEvent('click');Popup: Matt Walkers 3d Party Library
ol-popup
Diese Folien sind unter CC BY-SA veröffentlicht.