[go: nahoru, domu]

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

Getting map center point after drag #100

Open
SomewhatCloudy opened this issue Mar 8, 2022 · 4 comments
Open

Getting map center point after drag #100

SomewhatCloudy opened this issue Mar 8, 2022 · 4 comments

Comments

@SomewhatCloudy
Copy link

I've got a whole load of markers so I'd like to dynamically load them in based upon the map center. However I don't see an elegant way to get this data.

Ideally the dragend event (and other drag events) on should return the new center location data. Or is there a better way of doing this?

@aentwist
Copy link
aentwist commented Mar 22, 2022

Theoretically, you bind model the center and then you have it. Or, at least as a user that is what I would expect. Can you confirm whether that is working?

Edit: v-model:center="center"

<template>
  {{ center }}
  <GMapMap :center="center" />
</template>

<script setup>
import { reactive } from "vue";

const center = reactive({ lat: 0, lng: 0 });
</script>

@SomewhatCloudy
Copy link
Author

Nope, that didn't work. Thanks though.

@SomewhatCloudy
Copy link
Author

I had a look through the code and found these events on the GMapMap component:

  center_changed
  zoom_changed
  bounds_changed

Which also provides the relevant information as a callback. Hope this helps someone else in the future!

@aentwist
Copy link

Oops - of course binding it wouldn't propagate the update back. I would still consider this an issue, because this should be available through v-model here. With the power of Vue 3 v-model, there no longer needs to be any strange v-bind.sync patterns going on when there is more than one value to model.

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

2 participants