Skip to content

Instantly share code, notes, and snippets.

@bernardobelchior
Last active August 27, 2018 17:12
Show Gist options
  • Save bernardobelchior/44d9f2e5d86eef9a9ef6b34173848d18 to your computer and use it in GitHub Desktop.
Save bernardobelchior/44d9f2e5d86eef9a9ef6b34173848d18 to your computer and use it in GitHub Desktop.
style index.js
import View from 'ol/View';
import Map from 'ol/Map';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
import VectorLayer from 'ol/layer/Vector';
import VectorSource from 'ol/source/Vector';
import GeoJSON from 'ol/format/GeoJSON';
/* New imports */
import Style from 'ol/style/Style';
import Fill from 'ol/style/Fill';
window.onload = () => {
const target = document.getElementById('map')
new Map({
target,
view: new View({
center: [0, 0],
zoom: 2,
}),
layers: [
new TileLayer({
source: new OSM(),
}),
new VectorLayer({
source: new VectorSource({
url: 'https://raw.githubusercontent.com/bernardobelchior/openlayers-scratch-map-tutorial/start/countries.geojson',
format: new GeoJSON(),
}),
// New Style that fills the countries with the color #D4AF37
style: new Style({
fill: new Fill({
color: '#D4AF37',
})
})
})
]
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment