Load OL3 code only once we need it

This commit is contained in:
Lukas Martinelli
2016-12-22 18:08:42 +01:00
parent 607e920548
commit 3ee1473a49
8 changed files with 123 additions and 46 deletions

View File

@@ -8,9 +8,13 @@ const emptyStyle = ensureMetadataExists({
layers: [],
})
function generateId() {
return Math.random().toString(36).substr(2, 9)
}
function ensureHasId(style) {
if('id' in style) return style
style.id = Math.random().toString(36).substr(2, 9)
style.id = generateId()
return style
}
@@ -37,4 +41,5 @@ export default {
ensureMetadataExists,
emptyStyle,
indexOfLayer,
generateId,
}