What is the best way to create an interactive experience with MapLibre GL in Full Screen mode?

Hello, I am seeking a solution to create a map with the interactive option set to false, but once in full screen mode, I need this parameter to be true. Do you have any suggestions or ideas on how to achieve this?

 const _map = new MapGL({
        container: elementName,
        style: this.maplibreGlDataFromJsonService.getMapStyleConstants(),
        // style: `${mapStyle}?apiKey=${myAPIKey}`,
        center: [_lon, _lat],
        zoom: 9,
        interactive: false,
        transformRequest: (url: string, resourceType: any) => {
          return {
            url: url,
            headers: {
              'Authorization': 'Bearer ' + this.authService.accessToken,
              'mode': 'no-cors'
            }
          }
        }

      });
      let marker = new Marker()
        .setLngLat([_lon, _lat])
        .addTo(_map);

      var navigationBtns = new NavigationControl({showCompass: false, showZoom: false, visualizePitch: true});
      _map.addControl(navigationBtns, 'top-left');

      _map.addControl(new FullscreenControl({container: document.querySelector('.' + elementName)}));

Answer №1

Once a map is created, there doesn't appear to be a straightforward method to modify the interactive settings. However, you do have the option to activate or deactivate the user interaction handlers. More information on this can be found at .

One approach is to toggle these handlers using an event listener for the fullscreenchange event. Details about this event can be found at https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event.

Here is an example code snippet to achieve this:

const interactionHandlers = [
    'boxZoom', 'scrollZoom', 'dragPan', 'dragRotate', 'keyboard', 'doubleClickZoom', 'touchZoomRotate', 'touchPitch'
];

for (let handler of interactionHandlers) {
    map[handler].disable();
}

document.addEventListener('fullscreenchange', (event) => {
  if (document.fullscreenElement) {
    // Enable interaction when entering fullscreen mode
    for (let handler of interactionHandlers) {
        map[handler].enable();
    }
  } else {
    // Disable interaction when leaving fullscreen mode
    for (let handler of interactionHandlers) {
        map[handler].disable();
    }
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

The email input should be the same red color as the other inputs, but unfortunately it is

When I enter the email address with first name and last name, it shows as invalid. However, the color on the CSS does not match. I am confused about why there is a difference between the two. I tried changing the type of email to text, but still no luck. ...

Exploring routing within a Higher Order Component in React Native

I am looking to implement a file existence check on every page of my app. The idea is that if a specific file exists, the user should be redirected to another page. One solution I have considered is using a Higher Order Component (HOC) for this purpose. A ...

struggling with configuring dependency injection in NestJS and TypeORM

Struggling with integrating nestjs and typeorm for a simple CRUD application, specifically facing issues with dependency injection. Attempting to modularize the database setup code and import it. Encountering this error message: [ExceptionHandler] Nest ...

Generating dictionaries by utilizing data frames saved within a dictionary in Python

In my code, I have a for loop that iterates through and generates three data frames which are stored in a dictionary. From each of these data frames, I aim to create another dictionary, but the process is proving to be challenging. Here is how the repetit ...

Switching the focus of detection from a child to a parent

I am currently working on enhancing the functionality of my UI to display selections dynamically as they are selected or de-selected. import { Wizard } from './report-common'; import { Router } from '@angular/router'; import { DataServ ...

When using Vue with Vuetify, be aware that object literals can only specify known properties. In this case, the type 'vuetify' does not exist in the ComponentOptions of Vue with DefaultData

Started a fresh Vue project with TypeScript by following this guide: https://v2.vuejs.org/v2/guide/typescript.html If you don't have it installed yet, install Vue CLI using: npm install --global @vue/cli Create a new project and choose the "Manual ...

Flexbox is not properly repeating elements horizontally

I am struggling to align text boxes horizontally within ngFor loop, and I can't seem to pinpoint the mistake. Here is the HTML code from the parent component: <div class="maintenance-section"> <div class="yearly"> ...

Enable the use of empty spaces in ag-grid filter bars

I'm experiencing an issue with the ag grid filter. It seems to be disregarding white spaces. Is there a way to configure the grid to recognize blank spaces in the filter? Any suggestions for resolving this issue? Where can I find the option to accept ...

React's setState function failed to update the specified value within the set

In attempting to update the state values, I encountered an issue where the state did not get updated as expected. To troubleshoot, I included console logs at each line of code. handleFilter=(event)=> { console.log(this.state.answerStatus) // In ...

Launching the Skeleton feature in NextJS with React integration

I have been working on fetching a set of video links from an Amazon S3 bucket and displaying them in a video player component called HoverVideoPlayer. However, during the loading process, multiple images/videos scale up inside a Tailwind grid component, ca ...

Leverage the keyof operator for automatic determination of return type

My interface looks like this: interface ResourceState<ItemType> { rows: ItemType[], store: Record<String, ItemType> } To create a root state, I use the following structure: RootState{ car: ResourceState<Car> user: ResourceState<User&g ...

The new mui v5 Dialog is having trouble accepting custom styled widths

I am facing an issue with my MUI v5 dialog where I cannot seem to set its width using the style() component. import { Dialog, DialogContent, DialogTitle, Paper, Typography, } from "@mui/material"; import { Close } from "@mui/icons- ...

Issue with the Angular source maps are causing the sourceMappingUrl to break

After upgrading from Angular 7 to Angular 8, I've encountered an issue in Chrome and Firefox where there is an error in the dev console In Firefox: Error: JSON.parse: unexpected character at line 1 column 1 of the JSON data URL for Source Map: [url ...

Global Sass variables for responsive styling in Angular

I'm struggling to set up a global sass variable that defines the size of phones and tablets. Despite my efforts, I can't seem to successfully import it into my sass stylesheets. In my angular.json file: "stylePreprocessorOptions": { ...

What is the best way to target all select2 elements with a single button click?

Utilizing the Select2 feature of angular for multiple selection, I am in need of a function that allows me to select all elements with a single click on a button or checkbox. https://www.npmjs.com/package/ng-select2 My attempt at inserting all ele ...

Ways to deactivate a text area or mat-form-field

I need assistance with disabling a form field using Angular (4) + Angular Material and Reactive Forms. I have tried searching for syntax options like disabled="true", but haven't found the correct one yet. Can you please provide me with the right synt ...

I'm having trouble understanding why I keep encountering this error message: "SyntaxError: Unexpected token T in JSON at position 0 at JSON.parse (<anonymous>) at XMLHtt…"

I am in the process of implementing a download button feature that will allow users to download a document from my node.js server. Check out this stylish button: https://i.stack.imgur.com/s4CjS.png For the front-end, I am utilizing Angular as the fram ...

Utilize the grid system from Bootstrap to style HTML div elements

I am working on my angular application and need help with styling items in a Bootstrap grid based on the number of elements in an array. Here's what I'm looking to achieve: If there are 5 items in the array, I want to display the first two items ...

Does @angular/router have a similar function to ui-router's transition.from()?

I am currently in the process of updating an Angular application from ui-router to @angular/router (v6). There is a specific function that aims to retrieve the previous route. Below is the code snippet utilizing Transition from ui-router/core: const ...

What does the reportProgress function do in HTTP services with JavaScript?

Can someone explain the functionality of reportProgress in JavaScript, specifically when used with Angular Typescript? I am having trouble finding documentation on this. return this.httpClient.request<ProductResponse>('get',`${this.basePath ...