Last active
August 27, 2018 17:56
-
-
Save bernardobelchior/88da47d9555c41c9a8fd23fd45fb334b to your computer and use it in GitHub Desktop.
variables index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.onload = () => { | |
const target = document.getElementById('map') | |
// countriesSource is a variable holding the vector source with countries from countries.geojson | |
const countriesSource = new VectorSource({ | |
url: 'https://raw.githubusercontent.com/bernardobelchior/openlayers-scratch-map-tutorial/start/countries.geojson', | |
format: new GeoJSON(), | |
}) | |
new Map({ | |
target, | |
view: new View({ | |
center: [0, 0], | |
zoom: 2, | |
}), | |
layers: [ | |
new TileLayer({ | |
source: new OSM(), | |
}), | |
new VectorLayer({ | |
// Old instantiation moved to countriesSource | |
source: countriesSource, | |
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