Last active
August 27, 2018 17:55
-
-
Save bernardobelchior/aaf2a2349d45f9f8f58f93ade6d526c1 to your computer and use it in GitHub Desktop.
delete countries 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
/* New import at the top*/ | |
import { fromLonLat } from 'ol/proj' | |
// Wait for source to render | |
countriesSource.once('addfeature', () => { | |
// For each visited place | |
visitedPlaces.forEach(place => { | |
// Obtain map coordinates from longitude and latitude | |
const coordinate = fromLonLat(place) | |
// For each feature at coordinate, remove it from the source | |
// Because OpenLayers observes for changes, this will visually delete the countries from the map. | |
countriesSource.getFeaturesAtCoordinate(coordinate).forEach(f => countriesSource.removeFeature(f)) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment