Files
openlayers/examples/topojson.js
2017-12-17 02:07:34 -07:00

50 lines
1.3 KiB
JavaScript

import _ol_Map_ from '../src/ol/Map.js';
import _ol_View_ from '../src/ol/View.js';
import TopoJSON from '../src/ol/format/TopoJSON.js';
import _ol_layer_Tile_ from '../src/ol/layer/Tile.js';
import _ol_layer_Vector_ from '../src/ol/layer/Vector.js';
import _ol_source_TileJSON_ from '../src/ol/source/TileJSON.js';
import _ol_source_Vector_ from '../src/ol/source/Vector.js';
import _ol_style_Fill_ from '../src/ol/style/Fill.js';
import _ol_style_Stroke_ from '../src/ol/style/Stroke.js';
import _ol_style_Style_ from '../src/ol/style/Style.js';
var raster = new _ol_layer_Tile_({
source: new _ol_source_TileJSON_({
url: 'https://api.tiles.mapbox.com/v3/mapbox.world-dark.json?secure'
})
});
var style = new _ol_style_Style_({
fill: new _ol_style_Fill_({
color: 'rgba(255, 255, 255, 0.6)'
}),
stroke: new _ol_style_Stroke_({
color: '#319FD3',
width: 1
})
});
var vector = new _ol_layer_Vector_({
source: new _ol_source_Vector_({
url: 'data/topojson/world-110m.json',
format: new TopoJSON({
// don't want to render the full world polygon (stored as 'land' layer),
// which repeats all countries
layers: ['countries']
}),
overlaps: false
}),
style: style
});
var map = new _ol_Map_({
layers: [raster, vector],
target: 'map',
view: new _ol_View_({
center: [0, 0],
zoom: 1
})
});