1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
| import GeoJSON from 'ol/format/GeoJSON.js'; import Layer from 'ol/layer/Vector.js'; import Map from 'ol/Map.js'; import Source from 'ol/source/Vector.js'; import View from 'ol/View.js';
const format = new GeoJSON();
const map = new Map({ layers: [ new Layer({ background: '#1a2b39', source: new Source({ url: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_110m_land.geojson', format, }), style: { 'fill-color': 'darkgray', }, }), new Layer({ source: new Source({ url: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_50m_populated_places_simple.geojson', format, }), style: { 'circle-radius': ['get', 'scalerank'], 'circle-fill-color': 'gray', 'circle-stroke-color': 'white', 'circle-stroke-width': 0.5, }, }), new Layer({ source: new Source({ url: 'https://d2ad6b4ur7yvpq.cloudfront.net/naturalearth-3.3.0/ne_50m_populated_places_simple.geojson', format, }), declutter: true, style: [ { filter: ['>', ['get', 'pop_max'], 10_000_000], style: { 'text-value': ['get', 'nameascii'], 'text-font': '16px sans-serif', 'text-fill-color': 'white', 'text-stroke-color': 'gray', 'text-stroke-width': 2, }, }, { else: true, filter: ['>', ['get', 'pop_max'], 5_000_000], style: { 'text-value': ['get', 'nameascii'], 'text-font': '12px sans-serif', 'text-fill-color': 'white', 'text-stroke-color': 'gray', 'text-stroke-width': 2, }, }, ], }), ], target: 'map', view: new View({ center: [0, 0], zoom: 1, }), });
|