Skip to content

Looking for a way to call Maplibre's "flyTo" function #103

Closed Answered by dimfeld
wx007 asked this question in Q&A
Discussion options

You must be logged in to vote

3 options here, depending on your needs:

  1. The MapLibre component has a map prop which gets set to the MapLibre instance, so you can
<script>
  import { MapLibre } from 'svelte-maplibre'
  let map;

  $: map?.flyTo(newCoords);
</script>

<MapLibre bind:map>
  <!-- other stuff in here -->
</MapLibre>
  1. MapLibre exposes the map on its slot too, so if your buttons are in a control or something you can use that. The Controls example does it this way.

  2. The map events all include the map instance in their data, so you could reference event.detail.map in any event handler.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by wx007
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants