Skip to content

Commit

Permalink
fix: emit update:position event with coordinates in data projection
Browse files Browse the repository at this point in the history
  • Loading branch information
ghettovoice committed Apr 1, 2018
1 parent e6faff7 commit 90862b7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
34 changes: 22 additions & 12 deletions src/component/geoloc/geoloc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
* @module geoloc/geoloc
*/
import Geolocation from 'ol/geolocation'
import { Observable } from 'rxjs'
import { merge } from 'rxjs/observable'
import olCmp from '../../mixin/ol-cmp'
import projTransforms from '../../mixin/proj-transforms'
import useMapCmp from '../../mixin/use-map-cmp'
import { EPSG_3857 } from '../../ol-ext/consts'
import { hasGeolocation } from '../../util/assert'
import observableFromOlChangeEvent from '../../rx-ext/from-ol-change-event'
import { hasGeolocation } from '../../util/assert'
const props = {
tracking: {
Expand Down Expand Up @@ -163,18 +165,26 @@
hasGeolocation(this)
const ft = 100
const changes = observableFromOlChangeEvent(
this.$geolocation,
[
'accuracy',
'altitude',
'altitudeaccuracy',
'heading',
const changes = Observable::merge(
observableFromOlChangeEvent(
this.$geolocation,
[
'accuracy',
'altitude',
'altitudeaccuracy',
'heading',
'speed',
],
true,
ft,
),
observableFromOlChangeEvent(
this.$geolocation,
'position',
'speed',
],
true,
ft
true,
ft,
() => this.dataProjPosition,
)
)
this.subscribeTo(changes, ({ prop, value }) => {
Expand Down
5 changes: 3 additions & 2 deletions test/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<button @click="drawType = 'circle'">Circle</button>
<button @click="drawType = undefined">Reset</button>
</div>

<vl-map ref="map" @created="log('created')" @mounted="log('mounted')" @destroyed="log('destroyed')" @singleclick="clickCoord = $event.coordinate">
<vl-view ref="view" ident="view" :center.sync="center" :zoom.sync="zoom" :rotation.sync="rotation">
<vl-overlay slot-scope="view" v-if="view.center" :position="view.center">
Expand All @@ -20,7 +21,7 @@
</vl-overlay>
</vl-view>

<vl-geoloc projection="EPSG:3857">
<vl-geoloc data-projection="EPSG:4326" @update:position="log($event)">
<template slot-scope="ctx">
<vl-feature v-if="ctx.position" id="my-geoloc">
<vl-geom-point :coordinates="ctx.position" />
Expand Down Expand Up @@ -213,7 +214,7 @@
data () {
return {
zoom: 13,
center: fromLonLat([-80.0307892780456, 43.456341754866685]),
center: pointFromLonLat([-80.0307892780456, 43.456341754866685]),
rotation: 0,
points: [],
pointsLayer: true,
Expand Down

0 comments on commit 90862b7

Please sign in to comment.