#### Requirements
- *Dynamic* map interface with:
- Global basemaps
- Single images (*dynamic* layers)
- Measurements
- Scalebar
- Custom projections
- Performance (mainly rasters, tile cache)
- Open source (sustainability)
#### Main components
- [OpenLayers](https://openlayers.org/)
- [MapServer](https://mapserver.org/products.html)
- [MapServer Core](https://mapserver.org/documentation.html)
- [MapScript](https://mapserver.org/mapscript/index.html)
- [MapCache](https://mapserver.org/mapcache/index.html)
#### OpenLayers entry point
- [Tutorials](https://openlayers.org/en/latest/doc/tutorials/)
- Building an OpenLayers Application
- Node
- Parcel as bundler
- Javascript modules
Openlayers parcel tutorial
Custom Mars layer
MapServer: mars.map
MAP
NAME "MEx/HRSC global imagery and terrain data."
MAXSIZE 40960
UNITS meters
EXTENT -10668837.5 -5213575.0 10668900.0 5215725.0
WEB
METADATA
wms_onlineresource "https://maps.planet.fu-berlin.de/eqc-bin/wms?"
"wms_srs" "EPSG:4326"
wms_enable_request "*"
END
END #web
LAYER
NAME "MOLA-gray-hs"
TYPE RASTER
DATA MOLA-DTM-aeroid-hs-z3.tif
PROJECTION
proj=eqc
lat_ts=0
lat_0=0
lon_0=0
x_0=0
y_0=0
a=3396000
b=3396000
units=m
END
END #layer
END #map
Custom Mars layer
OpenLayers: index.js
...
import TileWMS from "ol/source/TileWMS";
const map = new Map({
target: 'map',
layers: [
new TileLayer({
source: new TileWMS({
url: "https://maps.planet.fu-berlin.de/eqc-bin/wms?",
params: { LAYERS: "MOLA-gray-hs"}
})
})
],
view: new View({
center: [0, 0],
zoom: 0,
projection: 'EPSG:4326'
})
});
Scale line
Openlayers: index.js
import {defaults as defaultControls, ScaleLine} from 'ol/control';
const map = new Map({
target: 'map',
layers: [
new TileLayer({
source: new TileWMS({
url: "https://maps.planet.fu-berlin.de/eqc-bin/wms?",
params: { LAYERS: "MOLA-gray-hs", VERSION: "1.1.1"}
})
})
],
controls: defaultControls().extend([
new ScaleLine({
units: 'metric'
})
]),
view: new View({
center: [0, 0],
zoom: 0,
projection: 'EPSG:4326'
})
});
MAP
NAME "MEx/HRSC global imagery and terrain data."
MAXSIZE 40960
UNITS meters
EXTENT -10668837.5 -5213575.0 10668900.0 5215725.0
WEB
METADATA
wms_onlineresource "https://maps.planet.fu-berlin.de/eqc-bin/wms?"
"wms_srs" "EPSG:49910 EPSG:4326"
wms_enable_request "*"
END
END
LAYER
NAME "MOLA-gray-hs"
TYPE RASTER
DATA MOLA-DTM-aeroid-hs-z3.tif
PROJECTION
proj=eqc
lat_ts=0
lat_0=0
lon_0=0
x_0=0
y_0=0
a=3396000
b=3396000
units=m
END
END #layer
Custom projection
Openlayers: index.js
import 'ol/ol.css';
import {Map, View} from 'ol';
import TileLayer from 'ol/layer/Tile';
import TileWMS from 'ol/source/TileWMS';
import {defaults as defaultControls, ScaleLine} from 'ol/control';
import {register} from 'ol/proj/proj4';
import {Projection} from 'ol/proj';
import proj4 from 'proj4';
proj4.defs('EPSG:49910', '+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=3396000 +b=3396000 +units=m +no_defs ');
register(proj4);
var projection = new Projection({
code: "EPSG:49910",
global: true,
extent: [-10668848.652, -5215881.563, 10668848.652, 5215881.563]
});
const map = new Map({
target: 'map',
layers: [
new TileLayer({
source: new TileWMS({
url: "https://maps.planet.fu-berlin.de/eqc-bin/wms?",
params: { LAYERS: "MOLA-gray-hs", VERSION: "1.1.1"}
})
})
],
controls: defaultControls().extend([
new ScaleLine({
units: 'metric'
})
]),
view: new View({
center: [0, 0],
zoom: 0,
projection: projection
})
});
LAYER
NAME "h3286_0000.ihs.04"
TYPE RASTER
DATA hrsc/mex4/eqc/ihs/h3286_0000.ihs.04.tif
PROJECTION
"init=epsg:49910"
END
METADATA
"wms_enable_request" "*"
"wms_abstract" "HRSC single sequence h3286_0000.ihs.04"
"wms_title" "h3286_0000.ihs.04"
END
END
Single image layer
Openlayers: index.js
import "ol/ol.css";
import { Map, View } from "ol";
import TileLayer from "ol/layer/Tile";
import TileWMS from "ol/source/TileWMS";
import { defaults as defaultControls, ScaleLine } from "ol/control";
import { register } from "ol/proj/proj4";
import { Projection, getTransform, get } from "ol/proj";
import { getDistance } from "ol/sphere";
import proj4 from "proj4";
proj4.defs("EPSG:49900", "+proj=longlat +a=3396000 +b=3396000 +no_defs ");
proj4.defs("EPSG:49910", "+proj=eqc +lat_ts=0 +lat_0=0 +lon_0=0 +x_0=0 +y_0=0 +a=3396000 +b=3396000 +units=m +no_defs ");
register(proj4);
var projection = new Projection({
code: "EPSG:49910",
global: true,
extent: [-10668848.652, -5215881.563, 10668848.652, 5215881.563],
getPointResolution: function(resolution, point) {
var toEPSG49900 = getTransform(get("EPSG:49910"), get("EPSG:49900"));
var vertices = [
point[0] - resolution / 2, point[1],
point[0] + resolution / 2, point[1]
];
vertices = toEPSG49900(vertices, vertices, 2);
return getDistance(vertices.slice(0, 2), vertices.slice(2, 4), 3396000);
}
});
const map = new Map({
target: "map",
layers: [
new TileLayer({
source: new TileWMS({
url: "https://maps.planet.fu-berlin.de/eqc-bin/wms?",
params: { LAYERS: "MOLA-gray-hs" }
})
}),
new TileLayer({
source: new TileWMS({
url: "https://maps.planet.fu-berlin.de/eqc-bin/wms?",
params: { LAYERS: "h3286_0000.ihs.04" }
})
})
],
controls: defaultControls().extend([
new ScaleLine({
units: "metric"
})
]),
view: new View({
center: [0, 0],
zoom: 0,
projection: projection
})
});