Created
August 27, 2018 16:59
-
-
Save bernardobelchior/be5664edca395e069f7e3f37117035d8 to your computer and use it in GitHub Desktop.
countries.geojson 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
import View from 'ol/View'; | |
import Map from 'ol/Map'; | |
import TileLayer from 'ol/layer/Tile'; | |
import OSM from 'ol/source/OSM'; | |
/* New imports */ | |
import VectorLayer from 'ol/layer/Vector'; | |
import VectorSource from 'ol/source/Vector'; | |
import GeoJSON from 'ol/format/GeoJSON'; | |
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 with VectorSource and the countries.geojson file as source | |
new VectorLayer({ | |
source: new VectorSource({ | |
url: 'https://raw.githubusercontent.com/bernardobelchior/openlayers-scratch-map-tutorial/start/countries.geojson', | |
format: new GeoJSON(), | |
}) | |
}) | |
] | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment