maptiler / maptiler-sdk-js

Maps SDK tailored for MapTiler Cloud powered by MapLibre GL JS
https://docs.maptiler.com/sdk-js/
BSD 3-Clause "New" or "Revised" License
79 stars 14 forks source link

`fullscreenstart` and `fullscreenend` event missing #68

Closed elgandoz closed 10 months ago

elgandoz commented 10 months ago

MapLibre has introduced the events fullscreenstart and fullscreenend since v3.0.0 (https://github.com/maplibre/maplibre-gl-js/pull/2128), but this 2 events do not trigger when using MapTiler SDK.

jonathanlurie commented 10 months ago

Hello @elgandoz , thanks for letting us know, I will look into it!

jonathanlurie commented 10 months ago

Hey, I just checked and it's actually there but a bit hidden. In the SDK there is a built-in control for fullscreen that you can add directly from the constructor, but if you do it this way, it's true that you cannot customise it or bind events to it. It's very possibly a point we are going to address in a near future, but in the mean time what I can propose is to set it manually:

import { Map, FullscreenControl } from "@maptiler/sdk";

const map = new Map({
  container: "map-container",
})

map.on("load", (evt) => {
  if (!map) return;

  const fsc = new FullscreenControl();
  map.addControl(fsc)

  fsc.on("fullscreenstart", (e) => {
    console.log("YEAH fullscreenstart !");
  })

});

Please let me know if that helps.

elgandoz commented 10 months ago

Thanks for the snippet, works great!