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

Add transformResponse Prop for Response Format Modification #5292

Open
moghani81 opened this issue Jan 5, 2025 · 1 comment
Open

Add transformResponse Prop for Response Format Modification #5292

moghani81 opened this issue Jan 5, 2025 · 1 comment
Labels
need more info Further information is requested

Comments

@moghani81
Copy link

User Story

As a developer, I want to use a transformResponse prop to process and modify server responses, so that I can decode encoded responses or apply custom transformations as needed before they are rendered in MapLibre.

Rationale

Many servers return responses in encoded or customized formats (e.g., compressed, encrypted, or containing metadata). There is currently no direct way to preprocess these responses before they are used in MapLibre.

Impact

Developers will continue to struggle with implementing custom logic to handle server responses, leading to fragmented and inconsistent solutions across projects. This could limit the adoption of MapLibre in scenarios requiring customized response handling.

  • Improved developer experience with a flexible and extensible API.
  • Easier integration with a wide variety of server configurations.
  • Reduced need for manual intervention in network handling, resulting in cleaner codebases.

Proposed Solution

Introduce a transformResponse prop in MapLibre, which would allow developers to define a custom transformation function. This function will take the raw server response as input and return the transformed data.

const map = new maplibregl.Map({
  container: 'map',
  style: 'https://example.com/styles.json',
  transformResponse: (response) => {
    // Example: Decode Base64
    const decoded = atob(response);
    return JSON.parse(decoded);
  },
});

By implementing this feature, MapLibre can better support modern use cases and offer flexibility to developers without adding significant complexity.

@HarelM
Copy link
Collaborator

HarelM commented Jan 5, 2025

I believe this is available using addProtocol...?

@HarelM HarelM added the need more info Further information is requested label Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need more info Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants