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

Feature Request: Support for Multiple Sources in Map Styles Using ol-maplibre-layer #1

Open
asebert-caue opened this issue Jul 29, 2024 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@asebert-caue
Copy link

Hello,

We commonly use Maputnik to create Maplibre styles (maplibre-style-spec) that combine multiple sources.

We have noticed that MaCarte uses the ol-mapbox-style library. After testing, we discovered that it can only load a single source. As stated in the documentation: "The style function will render all layers from the glStyle object that use the source of the first layer" (ol-mapbox-style - applyStyle).

However, we tested the ol-maplibre-layer library (ol-maplibre-layer). We were able to create multiple layers by loading Maplibre styles containing multiple sources into a map.

MapLibre is an open-source library, unlike Mapbox. Therefore, it might be more appropriate to use it for rendering style files, which aligns more with the open-source logic promoted by IGN.

Thank you for your work.

@Viglino
Copy link
Member

Viglino commented Jul 30, 2024

Hello,

I added the feature to handle multiple layers in vector tiles (using ol-maplibre-layer).
It seems to work.
NB1: only works for local files (no remote files)
NB2: the layer is no longer an ol layer and does not benefit from the selection/hover popup
NB3: an error message in the console when rendering on printing (to report)

Online test: https://ignf-ma-carte.github.io/mcutils/mcutils/charte.html?map=FfyxzB

@+

@Viglino Viglino added the enhancement New feature or request label Jul 30, 2024
@Viglino Viglino self-assigned this Jul 30, 2024
@asebert-caue
Copy link
Author

It's good news that it works.

NB1: only works for local files (no remote files)

Do you have more details about this issue? We have tested this library with an online style and did not encounter this problem.
Could it be a CORS issue?

Here is a link to a test style that mixes several sources:
https://tileserver.s-pass.org/styles/topo4colorsworld/style.json

And another link to visualize the rendering on MapLibre:
https://tileserver.s-pass.org/styles/topo4colorsworld/?vector#14.57/51.00246/2.06029

NB2: the layer is no longer an ol layer and does not benefit from the selection/hover popup

I understand, we are in a particular case reserved for experts. It might be possible to manage both types.
When you create styles with Maputnik, it is possible to choose the rendering mode MapLibre GL JS or OpenLayers.

CleanShot 2024-07-30 at 10 34 59@2x

This choice is then recorded in the Metadata property of the style:

{
  "version": 8,
  "name": "SPASS",
  "metadata": {
    "mapbox:autocomposite": false,
    "mapbox:type": "template",
    "maputnik:renderer": "mbgljs", // or "ol"
    "openmaptiles:version": "3.x",
    "openmaptiles:mapbox:owner": "openmaptiles",
    "openmaptiles:mapbox:source:url": "mapbox:https://openmaptiles.4qljc88t"
  }
}

If this information is not present, you could use the rendering mode with ol-mapbox to maintain the initial behavior of the viewer and thus retain the selection/hover and popup functionalities.
You can also rename this property, for example to mc:renderer.
The advantages and disadvantages of each rendering mode could be indicated in the documentation.

NB3: an error message in the console when rendering on printing (to report)

Indeed, the printing functionality can be problematic. This is why implementing both rendering modes could be a solution, with proper documentation.

@Viglino
Copy link
Member

Viglino commented Jul 30, 2024

NB1: only works for local files (no remote files)

Not a real issue: the caller has to know the layer type to use and switch between ol or Maplibre layer.
For now, it checks the number of layers and switches to Maplibre if more than one (that's why we need the local file). We have to add a parameter to set the layer type.

NB2: the layer is no longer an ol layer and does not benefit from the selection/hover popup

We have to add a hack to query the Maplibre map on click (but not implemented yet).

NB3: an error message in the console when rendering on printing

Not a real issue, the printing works but an error is fired on first attempt to render the map (but it finally renders).

@asebert-caue
Copy link
Author

Hello,

Thank you again for your responsiveness. I noticed that the feature is implemented in the main branch of mcutils and that version 3.4.5 of the mcviewer uses this version of mcutils. However, this version of the viewer is not yet in production, is that right?

Have a nice day.

@Viglino
Copy link
Member

Viglino commented Sep 10, 2024

Not yet!
v.3.4 is still in the testing phase and will be available at the end of September.
You can test it on the qualification site: https://qlf-macarte.ign.fr/

@asebert-caue
Copy link
Author

Thank you for the information. I will test it and provide detailed feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants