Update Sphere Mollweide example

This commit is contained in:
Tim Schaub
2022-01-07 13:55:34 -07:00
parent 197dd2e06d
commit 38d4a8f13f

View File

@@ -6,6 +6,7 @@ import VectorLayer from '../src/ol/layer/Vector.js';
import VectorSource from '../src/ol/source/Vector.js'; import VectorSource from '../src/ol/source/Vector.js';
import View from '../src/ol/View.js'; import View from '../src/ol/View.js';
import proj4 from 'proj4'; import proj4 from 'proj4';
import {Fill, Style} from '../src/ol/style.js';
import {register} from '../src/ol/proj/proj4.js'; import {register} from '../src/ol/proj/proj4.js';
proj4.defs( proj4.defs(
@@ -26,14 +27,25 @@ const sphereMollweideProjection = new Projection({
worldExtent: [-179, -89.99, 179, 89.99], worldExtent: [-179, -89.99, 179, 89.99],
}); });
const style = new Style({
fill: new Fill({
color: '#eeeeee',
}),
});
const map = new Map({ const map = new Map({
keyboardEventTarget: document, keyboardEventTarget: document,
layers: [ layers: [
new VectorLayer({ new VectorLayer({
source: new VectorSource({ source: new VectorSource({
url: 'data/geojson/countries-110m.geojson', url: 'https://openlayers.org/data/vector/ecoregions.json',
format: new GeoJSON(), format: new GeoJSON(),
}), }),
style: function (feature) {
const color = feature.get('COLOR_BIO') || '#eeeeee';
style.getFill().setColor(color);
return style;
},
}), }),
new Graticule(), new Graticule(),
], ],
@@ -41,6 +53,6 @@ const map = new Map({
view: new View({ view: new View({
center: [0, 0], center: [0, 0],
projection: sphereMollweideProjection, projection: sphereMollweideProjection,
zoom: 1, zoom: 2,
}), }),
}); });