Skip to content

Conversation

@ekdahl
Copy link
Contributor

@ekdahl ekdahl commented Jan 31, 2025

Will detect that it is an WMS map by looking for layers in options.

I decided to put all tile layer options in a separate variable because of this:

If any custom options not documented here are used, they will be sent to the WMS server as extra parameters in each request URL.

This means that for example url will be appended as parameter in the request if they are mixed with the tile layer options.

Here are samples of WMTS and WMS maps:

    public function leafletJsTileLayers(): array
    {
        return [
            (object) [
                'default'     => true,
                'label'       => 'WMTS map',
                'url'         => 'https://minkarta.lantmateriet.se/map/topowebbcache?layer=topowebb&tilematrixset=3857&Service=WMTS&Request=GetTile&TileMatrix={z}&TileCol={x}&TileRow={y}',
                'options'  => 
                    (object) [
                        'attribution' => '<a href="https://www.lantmateriet.se">Lantmäteriet</a>',
                        'maxZoom'     => 17,
                        'minZoom'     => 2,
                    ],
            ],
            (object) [
                'label'       => 'WMS map',
                'url'         => 'https://minkarta.lantmateriet.se/map/ortofoto',
                'options'  => 
                    (object) [
                        'attribution' => '<a href="https://www.lantmateriet.se">Lantmäteriet</a>',
                        'layers'      => 'Ortofoto_0.5,Ortofoto_0.4,Ortofoto_0.25,Ortofoto_0.16',
                        'maxZoom'     => 19,
                        'minZoom'     => 2,
                        'service'     => 'WMS',
                    ],
            ],
        ];
    }

@codecov
Copy link

codecov bot commented Jan 31, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 34.99%. Comparing base (80e1855) to head (f02d955).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #5110   +/-   ##
=========================================
  Coverage     34.99%   34.99%           
  Complexity    11520    11520           
=========================================
  Files          1189     1189           
  Lines         48502    48502           
=========================================
  Hits          16974    16974           
  Misses        31528    31528           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ekdahl
Copy link
Contributor Author

ekdahl commented May 27, 2025

Any opinion on this?
I guess an even cleaner approach is to explicitly set the service type, but that would require changes to existing modules if not providing backwards compatibility.

Would love to see WMS support in an upcoming release, so I can release a module with Swedish map services.

@ekdahl
Copy link
Contributor Author

ekdahl commented Aug 14, 2025

This PR should be non-intrusive for current modules...
Any hope of adding official WMS support (so I don't have to manually edit after each release)?

@fisharebest
Copy link
Owner

Can you explain what WMS is?

Google tells me there are lots of things called "Wxxxx Mapping Service".

Is this a different mapping provider?
Is this a different layer on an existing mapping provider?

@ekdahl
Copy link
Contributor Author

ekdahl commented Nov 7, 2025

WMS is Web Map Service, as in the protocol used for delivering maps by many map servers. See https://en.wikipedia.org/wiki/Web_Map_Service
The server generates the image file requested on demand (for the viewport size requested), unlike WMTS, XYZ or TMS services which delivers pre-rendered tiles.
For WMS, the layer(s) you want can to be supplied in the GetMap request, therefore 'layers' is added to the configuration.
See e.g. https://docs.qgis.org/3.40/en/docs/server_manual/services/wms.html#wms-getmap
And as you can see here, Leaflet already supports WMS: https://leafletjs.com/reference.html#tilelayer-wms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants