Andreas Hocevar, w3geo
Marc Jansen, terrestris
FOSSGIS 2024 | 22. März 2024 | Hamburg
import 'ol/ol.css';
import { Map, View } from 'ol';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
const map = new Map({
target: "map", // oder document.querySelector("#map"),
layers: [
new TileLayer({ source: new OSM() })
],
view: new View({
center: [0, 0],
zoom: 2
})
});
const basemap = new Group();
apply(
basemap,
"https://www.arcgis.com/sharing/rest/content/items/659e7c1b1e374f6c8a89eefe17b23380/resources/styles/root.json",
{
transformRequest: (url) =>
url.replace(/\/VectorTileServer$/, "/VectorTileServer/"),
},
);
map.addLayer(basemap);
const updatePosition = ({ coords: { latitude, longitude } }) => {
const position = [longitude, latitude];
positionFeature.setGeometry(new Point(position));
};
navigator.geolocation.watchPosition(updatePosition);
draw.on('drawend', ({feature}) => {
drawnFeature = feature;
map.removeInteraction(draw);
uppy.getPlugin('Dashboard').openModal();
});
uppy.on('complete', ({successful: [file]}) => {
drawnFeature.set('picture', file.uploadURL);
uppy.cancelAll();
uppy.getPlugin('Dashboard').closeModal();
});
const markers = new VectorSource();
const format = new GeoJSON();
// laden
if (localStorage.getItem('markers')) {
const geojson = localStorage.getItem('markers');
const features = format.readFeatures(geojson);
markers.addFeatures(features);
}
// speichern
markers.on('change', () => {
const features = markers.getFeatures();
const geojson = format.writeFeatures(features);
localStorage.setItem('markers', geojson);
});
import { readFileSync, writeFileSync } from 'fs';
import { TopoJSON, GeoJSON } from 'ol/format';
const in = readFileSync('input.topojson', 'utf8');
const features = new TopoJSON().readFeatures(in);
const out = new GeoJSON().writeFeatures(features);
writeFileSync('output.json', out);
`${baseUrl}tiles/11/1080/662.png?style=${styleUrl}`
z=11, x=1080, y=662, type="png"
const resolution = tilegrid.getResolution(z);
const center = tilegrid.getTileCoordCenter([z, x, y]);
await page.evaluate(
(center, resolution) => requestMapImage(center, resolution),
center,
resolution,
);
result = await page.screenshot({
encoding: 'binary',
type,
clip: { x: 256, y: 256, width: 512, height: 512 },
});
new TileLayer({
source: new XYZ({
url: `${baseUrl}tiles/{z}/{x}/{y}.png?style=${styleUrl}`,
tileSize: 512,
})
})
openlayers
:Diese Folien sind unter CC BY-SA veröffentlicht.