Skip to content

Commit

Permalink
fix debounced versions of refresh, recreate and remount, use se…
Browse files Browse the repository at this point in the history
…lf functions on each instance

code style, remove messy comments
  • Loading branch information
ghettovoice committed Nov 19, 2018
1 parent 8994260 commit 0716806
Show file tree
Hide file tree
Showing 40 changed files with 563 additions and 609 deletions.
952 changes: 476 additions & 476 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vuelayers",
"fullname": "VueLayers",
"version": "0.11.0-rc.6",
"version": "0.11.0-rc.7",
"description": "Web map Vue components with the power of OpenLayers",
"author": "Vladimir Vershinin <ghettovoice@gmail.com>",
"main": "./lib/index.js",
Expand Down
1 change: 0 additions & 1 deletion src/component/circle-geom/geom.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script>
/** @module circle-geom/geom */
import Circle from 'ol/geom/Circle'
import geometry from '../../mixin/geometry'
import { GEOMETRY_TYPE } from '../../ol-ext/consts'
Expand Down
3 changes: 0 additions & 3 deletions src/component/cluster-source/source.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
<script>
import sourceContainer from '../../mixin/source-container'
/**
* @module cluster-source/source
*/
import vectorSource from '../../mixin/vector-source'
import { createPointGeom, findPointOnSurface } from '../../ol-ext/geom'
import mergeDescriptors from '../../util/multi-merge-descriptors'
Expand Down
3 changes: 0 additions & 3 deletions src/component/feature/feature.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
</template>

<script>
/**
* @module feature/feature
*/
import Feature from 'ol/Feature'
import { Observable } from 'rxjs'
import { merge as mergeObs } from 'rxjs/observable'
Expand Down
1 change: 0 additions & 1 deletion src/component/geoloc/geoloc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
</template>

<script>
/** @module geoloc/geoloc */
import Geolocation from 'ol/Geolocation'
import { merge } from 'rxjs/observable'
import { olCmp, useMapCmp, projTransforms } from '../../mixin'
Expand Down
1 change: 0 additions & 1 deletion src/component/image-layer/layer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script>
/** @module image-layer/layer */
import ImageLayer from 'ol/layer/Image'
import layer from '../../mixin/layer'
Expand Down
3 changes: 0 additions & 3 deletions src/component/line-string-geom/geom.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<script>
/**
* @module line-string-geom/geom
*/
import LineString from 'ol/geom/LineString'
import geometry from '../../mixin/geometry'
import { GEOMETRY_TYPE } from '../../ol-ext/consts'
Expand Down
5 changes: 5 additions & 0 deletions src/component/map/map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,11 @@
*/
unmount () {
hasMap(this)
this.clearLayers()
this.clearInteractions()
this.clearOverlays()
this.unsubscribeAll()
this.$map.setTarget(undefined)
},
Expand Down
3 changes: 0 additions & 3 deletions src/component/mapbox-source/source.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<script>
/**
* @module mapbox-source/source
*/
import xyzSource from '../../mixin/xyz-source'
import { EPSG_3857, TILE_FORMAT } from '../../ol-ext/consts'
import { coalesce } from '../../util/minilo'
Expand Down
2 changes: 1 addition & 1 deletion src/component/modify-interaction/interaction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
setStyle (styles) {
if (styles !== this._styles) {
this._styles = styles
this.refresh()
this.scheduleRefresh()
}
},
/**
Expand Down
3 changes: 0 additions & 3 deletions src/component/multi-line-string-geom/geom.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<script>
/**
* @module multi-line-string-geom/geom
*/
import MultiLineString from 'ol/geom/MultiLineString'
import geometry from '../../mixin/geometry'
import { GEOMETRY_TYPE } from '../../ol-ext/consts'
Expand Down
3 changes: 0 additions & 3 deletions src/component/multi-point-geom/geom.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<script>
/**
* @module multi-point-geom/geom
*/
import MultiPoint from 'ol/geom/MultiPoint'
import geometry from '../../mixin/geometry'
import { GEOMETRY_TYPE } from '../../ol-ext/consts'
Expand Down
3 changes: 0 additions & 3 deletions src/component/multi-polygon-geom/geom.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<script>
/**
* @module multi-polygon-geom/geom
*/
import MultiPolygon from 'ol/geom/MultiPolygon'
import geometry from '../../mixin/geometry'
import { GEOMETRY_TYPE } from '../../ol-ext/consts'
Expand Down
3 changes: 0 additions & 3 deletions src/component/osm-source/source.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<script>
/**
* @module osm-source/source
*/
import OSMSource from 'ol/source/OSM'
import xyzSource from '../../mixin/xyz-source'
Expand Down
3 changes: 0 additions & 3 deletions src/component/point-geom/geom.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<script>
/**
* @module point-geom/geom
*/
import Point from 'ol/geom/Point'
import geometry from '../../mixin/geometry'
import { GEOMETRY_TYPE } from '../../ol-ext/consts'
Expand Down
3 changes: 0 additions & 3 deletions src/component/polygon-geom/geom.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<script>
/**
* @module polygon-geom/geom
*/
import Polygon from 'ol/geom/Polygon'
import geometry from '../../mixin/geometry'
import { GEOMETRY_TYPE } from '../../ol-ext/consts'
Expand Down
4 changes: 2 additions & 2 deletions src/component/sputnik-source/source.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script>
import xyzSource from '../../mixin/xyz-source'
/**
* Layer source to work with Sputnik.ru tile server.
* @module sputnik-source/source
*/
import xyzSource from '../../mixin/xyz-source'
const SPUTNIK_URL_TEMPLATE = 'http://tiles.maps.sputnik.ru/{z}/{x}/{y}.png?apikey={apikey}'
const SPUTNIK_ATTRIBUTIONS = '<a href="http://maps.sputnik.ru/" target="_blank">Спутник</a> ' +
Expand Down
26 changes: 6 additions & 20 deletions src/component/style-func/style.vue
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
<script>
/**
* Style function component for advanced styling.
* Plays the role of both a style that mounts itself to style target component (vl-layer-vector, vl-feature & etc.)
* and style target for inner style containers (vl-style-box) as fallback style.
* @module style-func/style
*/
import { first as firstObs } from 'rxjs/operators'
import { observableFromOlEvent } from '../../rx-ext'
import style from '../../mixin/style'
import stylesContainer from '../../mixin/styles-container'
import { hasMap } from '../../util/assert'
import { warn } from '../../util/log'
import { isFunction, noop } from '../../util/minilo'
import mergeDescriptors from '../../util/multi-merge-descriptors'
/**
* Style function component for advanced styling.
* Plays the role of both a style that mounts itself to style target component (vl-layer-vector, vl-feature & etc.)
* and style target for inner style containers (vl-style-box) as fallback style.
*/
const props = {
/**
* @type {function(): function(feature: Feature): Style}
Expand Down Expand Up @@ -104,20 +102,8 @@
* @return {Promise}
*/
refresh () {
if (this.$olObject == null) return Promise.resolve()
// recreate style
return this.recreate()
.then(() => {
if (!this.$map) {
return
}
this.$map.render()
return observableFromOlEvent(this.$map, 'postcompose')
.pipe(firstObs())
.toPromise()
})
},
}
Expand Down
3 changes: 0 additions & 3 deletions src/component/tile-layer/layer.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<script>
/**
* @module tile-layer/layer
*/
import TileLayer from 'ol/layer/Tile'
import layer from '../../mixin/layer'
Expand Down
1 change: 0 additions & 1 deletion src/component/vector-layer/layer.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script>
/** @module vector-layer/layer */
import VectorLayer from 'ol/layer/Vector'
import vectorLayer from '../../mixin/vector-layer'
Expand Down
18 changes: 12 additions & 6 deletions src/component/vector-source/source.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script>
import { fetch } from 'whatwg-fetch'
import VectorSource from 'ol/source/Vector'
import { fetch } from 'whatwg-fetch'
import vectorSource from '../../mixin/vector-source'
import { getFeatureId } from '../../ol-ext/feature'
import { createGeoJsonFmt } from '../../ol-ext/format'
import { loadingAll } from '../../ol-ext/load-strategy'
import { transform } from '../../ol-ext/proj'
import { constant, difference, isFinite, isFunction, stubArray, isEmpty } from '../../util/minilo'
import { constant, difference, isEmpty, isFinite, isFunction, stubArray } from '../../util/minilo'
const props = {
/**
Expand Down Expand Up @@ -195,10 +195,16 @@
credentials: 'same-origin',
mode: 'cors',
}).then(response => response.text())
.then(text => vm.$source.getFormat().readFeatures(text, {
featureProjection: vm.viewProjection,
dataProjection: vm.resolvedDataProjection,
}))
.then(text => {
if (!vm.$source) {
return []
}
return vm.$source.getFormat().readFeatures(text, {
featureProjection: vm.viewProjection,
dataProjection: vm.resolvedDataProjection,
})
})
}
}
Expand Down
3 changes: 0 additions & 3 deletions src/component/wmts-source/source.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<script>
/**
* @module wmts-source/source
*/
import WMTSSource from 'ol/source/WMTS'
import WMTSTileGrid from 'ol/tilegrid/WMTS'
import tileSource from '../../mixin/tile-source'
Expand Down
3 changes: 0 additions & 3 deletions src/component/xyz-source/source.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
<script>
/**
* @module xyz-source/source
*/
import xyzSource from '../../mixin/xyz-source'
const props = {}
Expand Down
3 changes: 0 additions & 3 deletions src/mixin/features-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,4 @@ const methods = {
export default {
mixins: [projTransforms],
methods,
destroyed () {
this.clearFeatures()
},
}
2 changes: 1 addition & 1 deletion src/mixin/ident-map.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @module mixin/ident-map */
import Vue from 'vue'
import IdentityMap from '../util/identity-map'
import { identity } from '../util/minilo'

// todo uncomment when IE 11 will die
// const IDENTITY_MAP_PROP = Symbol('identityMap')
const IDENTITY_MAP_PROP = 'identityMap'
Expand Down
1 change: 0 additions & 1 deletion src/mixin/image-source.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { EPSG_3857 } from '../ol-ext/consts'
/** @module mixin/image-source */
import source from './source'

/**
Expand Down
14 changes: 0 additions & 14 deletions src/mixin/image-style.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import style from './style'
import { first as firstObs } from 'rxjs/operators'
import { observableFromOlEvent } from '../rx-ext'

const props = {
}
Expand Down Expand Up @@ -45,20 +43,8 @@ const methods = {
* @return {Promise}
*/
refresh () {
if (this.$olObject == null) return Promise.resolve()
// recreate style
return this.recreate()
.then(() => {
if (!this.$map) {
return
}

this.$map.render()

return observableFromOlEvent(this.$map, 'postcompose')
.pipe(firstObs())
.toPromise()
})
},
}

Expand Down
3 changes: 0 additions & 3 deletions src/mixin/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @module mixin
*/
export arcgisSource from './arcgis-source'
export featuresContainer from './features-container'
export geometry from './geometry'
Expand Down
3 changes: 0 additions & 3 deletions src/mixin/interactions-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,4 @@ const methods = {

export default {
methods,
destroyed () {
this.clearInteractions()
},
}
8 changes: 1 addition & 7 deletions src/mixin/layer.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
/**
* @module mixin/layer
*/
import uuid from 'uuid/v4'
import Vue from 'vue'
import { hasLayer, hasMap } from '../util/assert'
Expand All @@ -10,10 +7,7 @@ import cmp from './ol-virt-cmp'
import sourceContainer from './source-container'
import useMapCmp from './use-map-cmp'

/**
* @vueProps
*/
const props = /** @lends module:mixin/layer# */{
const props = {
id: {
type: [String, Number],
default: () => uuid(),
Expand Down
3 changes: 0 additions & 3 deletions src/mixin/layers-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,4 @@ const methods = {

export default {
methods,
destroyed () {
this.clearLayers()
},
}
Loading

0 comments on commit 0716806

Please sign in to comment.