Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

moveend on LMap fires too much in certain case #191

Closed
iamvdo opened this issue Jun 21, 2018 · 5 comments
Closed

moveend on LMap fires too much in certain case #191

iamvdo opened this issue Jun 21, 2018 · 5 comments

Comments

@iamvdo
Copy link

iamvdo commented Jun 21, 2018

Take this little snippet:

<template>
  <v-map
    id="map"
    :zoom="11"
    :center="[48.85, 2.35]"
    @moveend="handleMoveend">
    <v-tilelayer url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"></v-tilelayer>
  </v-map>
</template>

<script>
export default {
  data () {
    return {
      data: []
    }
  },
  methods: {
    handleMoveend(e) {
      console.log('movend');
      this.updateData();
    },
    updateData() {
      this.data.push('foo');
    }
  }
}
</script>

If you're moving the map, moveend fires once (each time) as expected.

Now, use data from <template>, eg:

<template>
  ...
    <v-tilelayer url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"></v-tilelayer>
    {{data.length}}
  </v-map>
</template>

If you're moving the map now, moveend fires many times.

Find out that if you set center from data, it no longer happens. Eg:

<template>
  <v-map
    id="map"
    :zoom=11
    :center="center"
    ...
</template>

<script>
...
data() {
    return {
        center: [48.85, 2.35]
    }
}
...

Live demo: http://jsfiddle.net/zmp5n2L0/7/ (be careful, moving the map can freeze browser)

@vdcrea
Copy link

vdcrea commented Jun 29, 2018

Playing around Leaflet and Vue, I have noticed that Leaflet doesn't go exactly where you ask, lat lng are rounded http://stage.vdcrea.com/leaflet/roundcenter.mp4

This is know bug (or feature) Leaflet/Leaflet#922 (comment) Leaflet/Leaflet#426

The center is setted using L.Map.getCenter() witch is not the same as the center from the prop.
https://github.com/KoRiGaN/Vue2Leaflet/blob/master/src/components/LMap.vue#L109

The prop center is watched by utils props binder and the following method is triggered https://github.com/KoRiGaN/Vue2Leaflet/blob/master/src/components/LMap.vue#L184

My guess is that the diff between the asked coordinates and the leaflet ones creates the infinite loop. My two cents

@pixelizedPeanut
Copy link

I have the exactly the same problem, where I need to switch from one city to another, and the slight changed centre makes the map be completely off :(

@DonNicoJs
Copy link
Member

@pixelizedPeanut Could you try to use the next branch as specified in this comment:
#235 (comment)
and see if it solves your problem ?

@DonNicoJs
Copy link
Member

Version 1.1.1 is out on npm and should fix this issue @pixelizedPeanut could you test and see if ti resolve your issue ?

@DonNicoJs
Copy link
Member

Closing due to inactivity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants