UNPKG

1.14 kBJavaScriptView Raw
1goog.require('ol.Graticule');
2goog.require('ol.Map');
3goog.require('ol.View');
4goog.require('ol.format.GeoJSON');
5goog.require('ol.layer.Vector');
6goog.require('ol.proj.Projection');
7goog.require('ol.source.Vector');
8
9
10proj4.defs('ESRI:53009', '+proj=moll +lon_0=0 +x_0=0 +y_0=0 +a=6371000 ' +
11 '+b=6371000 +units=m +no_defs');
12
13// Configure the Sphere Mollweide projection object with an extent,
14// and a world extent. These are required for the Graticule.
15var sphereMollweideProjection = new ol.proj.Projection({
16 code: 'ESRI:53009',
17 extent: [-9009954.605703328, -9009954.605703328,
18 9009954.605703328, 9009954.605703328],
19 worldExtent: [-179, -89.99, 179, 89.99]
20});
21
22var map = new ol.Map({
23 keyboardEventTarget: document,
24 layers: [
25 new ol.layer.Vector({
26 source: new ol.source.Vector({
27 url: 'data/geojson/countries-110m.geojson',
28 format: new ol.format.GeoJSON()
29 })
30 })
31 ],
32 target: 'map',
33 view: new ol.View({
34 center: [0, 0],
35 projection: sphereMollweideProjection,
36 resolutions: [65536, 32768, 16384, 8192, 4096, 2048],
37 zoom: 0
38 })
39});
40
41new ol.Graticule({
42 map: map
43});