Conversation
|
🚀 Deployed on https://69225ff67796acb4254450a0--opengeos.netlify.app |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for custom HTTP headers (specifically authorization headers) to MapLibreMap, enabling access to private tile servers that require authentication. The implementation uses MapLibre GL JS's transformRequest callback to inject custom headers into all tile requests.
Key changes:
- Added
request_headersparameter to MapLibreMap for passing custom HTTP headers - Implemented
transformRequestcallback in JavaScript to apply headers to tile requests - Created comprehensive documentation with examples showing various authentication scenarios
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| anymap/maplibre.py | Added request_headers traitlet with documentation in the class docstring |
| anymap/static/maplibre_widget.js | Implemented transformRequest callback to inject custom headers into tile requests |
| docs/examples/maplibre/authorization_headers_example.ipynb | Added comprehensive notebook with 6 examples demonstrating authorization header usage |
Comments suppressed due to low confidence (1)
anymap/maplibre.py:134
- The
request_headersparameter is missing from the__init__method signature. While it can be passed via**kwargs, it should be an explicit parameter for better API discoverability and type checking. Addrequest_headers: Dict[str, str] = Noneto the parameter list and include it in the Args section of the docstring.
def __init__(
self,
center: List[float] = [0, 20],
zoom: float = 1.0,
style: Union[str, Dict[str, Any]] = "dark-matter",
width: str = "100%",
height: str = "680px",
bearing: float = 0.0,
pitch: float = 0.0,
controls: Dict[str, str] = {
"navigation": "top-right",
"fullscreen": "top-right",
"scale": "bottom-left",
"globe": "top-right",
"layers": "top-right",
},
projection: str = "mercator",
add_sidebar: bool = False,
sidebar_visible: bool = False,
sidebar_width: int = 360,
sidebar_args: Optional[Dict] = None,
layer_manager_expanded: bool = True,
**kwargs: Any,
) -> None:
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.