Skip to content

Commit

Permalink
Fix #315
Browse files Browse the repository at this point in the history
  • Loading branch information
ghettovoice committed May 31, 2020
1 parent c3c7ea6 commit 1589071
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build/webpack.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const baseWebpackConfig = require('./webpack.base.config')
const utils = require('./utils')

const webpackConfig = merge(baseWebpackConfig, {
devtool: '#cheap-module-eval-source-map',
// devtool: '#cheap-module-eval-source-map',
plugins: [
new webpack.HotModuleReplacementPlugin(),
// https://github.com/ampedandwired/html-webpack-plugin
Expand Down
6 changes: 3 additions & 3 deletions src/component/vector-source/source.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import VectorSource from 'ol/source/Vector'
import { vectorSource } from '../../mixin'
import { createGeoJsonFmt, getFeatureId, initializeFeature, loadingAll, transform } from '../../ol-ext'
import { constant, difference, isEqual, isFinite, isFunction, stubArray } from '../../util/minilo'
import { constant, difference, isEqual, isFinite, isFunction, stubArray, isArray, isString } from '../../util/minilo'
import { makeWatchers } from '../../util/vue-helpers'
export default {
Expand Down Expand Up @@ -82,10 +82,10 @@
resolution,
this.resolvedDataProjection,
)
if (!Array.isArray(features)) {
if (isString(features) && features !== '') {
features = this.readSourceData(features)
}
if (Array.isArray(features)) {
if (isArray(features)) {
this.addFeatures(features)
}
}
Expand Down
23 changes: 14 additions & 9 deletions test/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
</vl-layer-tile>

<vl-layer-vector>
<vl-source-vector :features.sync="features"></vl-source-vector>
<vl-source-vector ref="vectorSource" :features.sync="features" :loader-factory="loader"></vl-source-vector>
<vl-style-func :factory="styleFactory" />
</vl-layer-vector>

Expand All @@ -22,7 +22,7 @@
</template>

<script>
import { createStyle } from '../src/ol-ext'
import { createStyle, readGeoJsonFeature } from '../src/ol-ext'
export default {
name: 'app',
Expand All @@ -40,17 +40,17 @@
return this.selectedFeatures.map(({ id }) => id)
},
},
mounted () {
this.loadFeatures().then(features => {
this.features = features.map(Object.freeze)
})
},
methods: {
loader () {
return async () => {
await this.loadFeatures()
}
},
loadFeatures() {
return new Promise(resolve => {
setTimeout(() => {
// generate GeoJSON random features
resolve([{
const features = [{
type: "Feature",
geometry: {
type: 'Point',
Expand Down Expand Up @@ -136,7 +136,12 @@
active: false,
},
},
])
]
features.forEach(feature => {
feature = readGeoJsonFeature(feature)
this.$refs.vectorSource.addFeature(feature)
})
resolve()
}, 3000)
})
},
Expand Down

0 comments on commit 1589071

Please sign in to comment.