maplibre / maplibre-native-qt

MapLibre Native Qt Bindings and Qt Location Plugin
https://maplibre.org/maplibre-native-qt/docs/
39 stars 15 forks source link

Unable to change map style #38

Closed emericg closed 11 months ago

emericg commented 1 year ago

Describe the bug I am not able to register new styles or map provider, it seems to be stuck on the "basic" MapLibre style.

To Reproduce

  1. Build the plugin git version for Qt 6.5+
  2. Try to set a plugin parameter to add an additional style
  3. Check if supportedMapTypes contains more than the default style

Expected behavior By default the supportedMapTypes contains only one style QGeoMapType(1, maplibre://maps/style, Basic, false, false, , ). After adding plugin parameters like this there should be new entries in supportedMapTypes:

PluginParameter { name: "maplibre.mapping.additional_style_urls"; value: "https://tiles.versatiles.org/styles/colorful.json" }

PluginParameter { name: "maplibre.mapping.additional_style_urls"; value: "https://api.maptiler.com/maps/streets/style.json?key=get_your_own_OpIi9ZULNHzrESv6T2vL"; }

For instance with the osm plugin I can switch between styles :

qml: - supported map types: QGeoMapType(1, Street Map, Street map view in daylight mode, false, false, , ),QGeoMapType(2, Satellite Map, Satellite map view in daylight mode, false, false, , ),QGeoMapType(10, Cycle Map, Cycle map view in daylight mode, false, false, , ),QGeoMapType(6, Transit Map, Public transit map view in daylight mode, false, false, , ),QGeoMapType(6, Night Transit Map, Public transit map view in night mode, false, true, , ),QGeoMapType(4, Terrain Map, Terrain map view, false, false, , ),QGeoMapType(8, Hiking Map, Hiking map view, false, false, , )```

Platform information:

kebekus commented 1 year ago

Same problem here. Looking at the source code, I found that the name of the plugin parameter has changed to "maplibre.map.styles". I tried that name, and it works.

The plugin parameter names seem wrong in the examples.

emericg commented 1 year ago

Looks like you are right! The solution was quite simple ;)

ntadej commented 1 year ago

OK, will fix the examples and remove the default map source so it's clear it needs to be set.