Leaflet integration of SwissTopo map

909 views
Skip to first unread message

raf...@gmail.com

unread,
Jul 7, 2016, 7:19:46 AM7/7/16
to GeoAdmin API
Hello, I'm a bit new to all web developement but I would love to include the Swisstopo map on my leaflet map. (see http://zoziologie.raphaelnussbaumer.com/improved-biolovision-visualisation/)

var wmsLayer = L.tileLayer.wms('http://wmts.geo.admin.ch/1.0.0/WMTSCapabilities.xml', {
     layers: 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale'
}).addTo(map);

If I understand correctly, the map should be free (https://api3.geo.admin.ch/api/faq/index.html#available-layers), is that right ?

I've also try the code provided in https://www.procrastinatio.org/assets/js/native-wmts-leaflet.js. And that also does not seem to work

1. Is the first method suppose to work ?  O should I use the second one (from Marc Monnerat )?
2. If I need a swisstopo web access, How can I get it ? The link given https://www.swisstopo.admin.ch/internet/swisstopo/en/home/products/services/web_services/webaccess.html seems to be broken.

Thanks in advance for you help,


Gilbert Jeiziner

unread,
Jul 7, 2016, 7:26:12 AM7/7/16
to geoadm...@googlegroups.com, raf...@gmail.com
Hi

while the data is free, you need to register to be able to use it:

https://www.geo.admin.ch/de/geo-dienstleistungen/geodienste/darstellungsdienste-webmapping-webgis-anwendungen/programmierschnittstelle-api/anmeldung.html

There is a maximum quota that you can use for free. Once you have
registered a domain, it should work.

Gilbert
> --
> You received this message because you are subscribed to the Google
> Groups "GeoAdmin API" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to geoadmin-api...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout [1].
>
>
> Links:
> ------
> [1] https://groups.google.com/d/optout

Raphaël Nussbaumer

unread,
Jul 8, 2016, 7:05:17 AM7/8/16
to Gilbert Jeiziner, geoadm...@googlegroups.com
Hi,
I finally managed to be registered! However, my script is still not working:
    layers: 'ch.swisstopo.pixelkarte-farbe-pk1000.noscale'
}).addTo(map)


--
Raphaël.

Loïc Gasser

unread,
Jul 8, 2016, 7:24:28 AM7/8/16
to geoadm...@googlegroups.com, Gilbert Jeiziner
Hi Raphael,

are you sure about L.tileLayer.wms ?

It is a WMTS Capabilities you're trying to use here and not a WMS. Which service are you trying to use?

My advise would be to use ch.swisstopo.pixelkarte-farbe rather than the noscale one.

You should generate requests that look like:


Kind Regards,

Loïc

For more options, visit https://groups.google.com/d/optout.

Loïc Gasser

unread,
Jul 8, 2016, 7:59:19 AM7/8/16
to geoadm...@googlegroups.com
Hi Raphael,

here is a codepen.


Hope this helps

Raphaël Nussbaumer

unread,
Jul 8, 2016, 8:20:45 AM7/8/16
to geoadm...@googlegroups.com
Great ! Thank you so much ! 

Just to try to understand: https://github.com/mylen/leaflet.TileLayer.WMTS is using the KVP encoding while Swiss Topo is using REST ?

--
Raphaël.

Loïc Gasser

unread,
Jul 8, 2016, 8:32:35 AM7/8/16
to geoadm...@googlegroups.com
Yes indeed.

You can now access all our layers in EPSG:3857.

See also:

for a complete list of layers. Enjoy!

Some contextual data might be of intrest for your use case.

Kind Regards,

Loïc

Raphaël Nussbaumer

unread,
Jul 13, 2016, 4:30:55 AM7/13/16
to geoadm...@googlegroups.com
thanks!

--
Raphaël.
Reply all
Reply to author
Forward
0 new messages