Skip to content

Instantly share code, notes, and snippets.

@bernardobelchior
Last active August 27, 2018 17:55
Show Gist options
  • Save bernardobelchior/aaf2a2349d45f9f8f58f93ade6d526c1 to your computer and use it in GitHub Desktop.
Save bernardobelchior/aaf2a2349d45f9f8f58f93ade6d526c1 to your computer and use it in GitHub Desktop.
delete countries index.js
/* 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