-
-
Notifications
You must be signed in to change notification settings - Fork 735
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
projection setting on map object (outside style) #4909
Comments
Thanks for opening this issue! Yes I had the same thoughts and added it to the v5 issue. |
@HarelM , I've become a bit unsure if it's sufficient. If the Before: async function downloadStyleObject(url) {
return await fetch(url)
.then((response) => response.json())
.then((data) => data)
.catch((error) => {
console.error("Error fetching or parsing JSON:", error);
return null;
});
}
let style = await downloadStyleObject('https://.../style.json?APIKEY=)
style.projection = {type: "globe"}
style.layers.filter(layer=>layer.name != "waterway")
style: style After: style: 'https://.../style.json",
styleOverride: (style)=>{
style.projection = {type: "globe"}
style.layers.filter(layer=>layer.name != "waterway")
} My hesitation comes from cases like below link, where I'm loading a proprietary satellite layer form a url, and then have a need to manipulate the style projection, layers, sources, terrain, sky etc. afterwards. There's a bit more to the design though, because say you have a layer shifter (sat / street), and you change the style with setStyle(), then you might want to have a different set of modifications, i.e. because it's only e.g. sat style that has a broken layer, and the names in the arrays of style.layers are different. And that would mean that the url, and the override is linked, requiring an api like After: style: {
url: 'https://.../style.json",
override: (style)=>{
style.projection = {type: "globe"}
style.layers.filter(layer=>layer.name != "waterway")
}
} |
You can supply a style diff method, this already exists right now. |
@HarelM , interesting, can i tell from within that method what the new style url is, so that the logic can be conditioned on that? |
No, style URL is not part of the |
User Story
I'd like to be able to set a projection on my map, and change style at will.
Rationale
If i have a style object, then I can apply the projection directly with a spread, or by editing the object before setting the style:
GoogleSatStyle.projection = { type: 'globe' }
or
style: { ...GoogleSatStyle, projection: { type: 'globe' } }
,If I have a style url, with or without api keys (like Positron "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"), then it's more tedious, because I'd have to download the style, then editing it, and then setting it like above, every time setStyle is called, like:
and then the same as prior
style: {...(await downloadStyleObject(getBasemap())), projection: {type:'globe'}}
Impact
It would be an override, so if it's not set there is no impact
The text was updated successfully, but these errors were encountered: