OpenStreetMaps Layer in Geoadmin API

215 views
Skip to first unread message

francesco romeo

unread,
Jun 3, 2019, 11:07:25 AM6/3/19
to GeoAdmin API
I would like to place an OpenStreetMaps layer in my Map.

I tryed but i keep getting strange mistakes that i am not getting with Openlayers.
Geoadmin API is based on Openlayers so i thought it would have been easy.

I know I can have problems with the coordinate system, but i thought at least I would have been able to display the map.

Is it possible?
How can i do?


Marc Monnerat

unread,
Jun 3, 2019, 3:50:29 PM6/3/19
to geoadmin-api
Hello Francesco,

Well, the GeoAdmin API is using the Swiss projection, the old one LV03 (EPSG:21781) or the new one LV95 (EPSG:2056) depending on what version you are using.
On the other side, OSM is generally base on the spherical Mercator (EPSG:3857) or simple WGS84 (EPSG:4326).

What kind of data are you trying to display 3D raster or vector? Have you an example I may look at?

Regards,

Marc

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/d934254c-9758-4ae8-abb1-3745d087c110%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
-- ἡ φύσις οὐδὲν ποιεῖ ἅλματα.

francesco romeo

unread,
Jun 4, 2019, 6:09:59 AM6/4/19
to GeoAdmin API
Hallo Mark I just would like to have the OSM street map layer as an alternative to the swisstopo streetmap layer.

instead of this: ch.swisstopo.pixelkarte-farbe

Is this somwhow possible?

have a nice day!


On Monday, June 3, 2019 at 9:50:29 PM UTC+2, Marc Monnerat wrote:
Hello Francesco,

Well, the GeoAdmin API is using the Swiss projection, the old one LV03 (EPSG:21781) or the new one LV95 (EPSG:2056) depending on what version you are using.
On the other side, OSM is generally base on the spherical Mercator (EPSG:3857) or simple WGS84 (EPSG:4326).

What kind of data are you trying to display 3D raster or vector? Have you an example I may look at?

Regards,

Marc

Le lun. 3 juin 2019 à 17:07, francesco romeo <francesco...@gmail.com> a écrit :
I would like to place an OpenStreetMaps layer in my Map.

I tryed but i keep getting strange mistakes that i am not getting with Openlayers.
Geoadmin API is based on Openlayers so i thought it would have been easy.

I know I can have problems with the coordinate system, but i thought at least I would have been able to display the map.

Is it possible?
How can i do?


--
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 geoadm...@googlegroups.com.

Marc Monnerat

unread,
Jun 4, 2019, 7:55:18 AM6/4/19
to geoadmin-api
Hello Francesco,

You could combine both sources using the spherical Mercator projection. For inspiration (ugly, but you get the idea):



Regards,

Marc

To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/a4317731-9922-4380-999a-02576d08b975%40googlegroups.com.

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

francesco romeo

unread,
Jun 4, 2019, 8:38:03 AM6/4/19
to GeoAdmin API
Hi Mark,

I need just the one from OSM.

the problem is that this:
import OSM from 'ol/source/OSM.js';

declare  let ga;
declare let ol;

this.map = new ga.Map({    //creating the map
target: 'map-openlayers',
layers: [
new ol.layer.Tile({
source: new OSM()
})
],
view: new ol.View({
...

Does not work.
I think ga (geoadminAPI) does not like the OSM object.

In your example you are not using geoadminAPI but only Openlayers and a swisstopo layer, is this correct?

Thanks,
Have a nice day!

On Tuesday, June 4, 2019 at 1:55:18 PM UTC+2, Marc Monnerat wrote:
Hello Francesco,

You could combine both sources using the spherical Mercator projection. For inspiration (ugly, but you get the idea):



Regards,

Marc

David Oesch

unread,
Jun 4, 2019, 10:28:16 AM6/4/19
to geoadm...@googlegroups.com

Marc Monnerat

unread,
Jun 5, 2019, 3:44:34 AM6/5/19
to geoadmin-api
Hello Francesco,

The Geoadmin API is very old now and not updated anymore. It is base on OL3 (default) or OL4 (http://api3.geo.admin.ch/loader.js?version=4.4.2) for the latest.
So, It is better to use pure OL. Besides that, I don't think OL4 has client-side reprojection (you can't mix sources of different projections)

Regards,

Marc


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

francesco romeo

unread,
Jun 7, 2019, 12:11:04 PM6/7/19
to GeoAdmin API
Hello Mark,

Ok but i was searching for code examples with OL4+ and I was not able to display the layers,
can you give me an example code snippet to display: 'ch.swisstopo.swissimage'?
I am using angular with OL as an external javascript library.

Thanks have a nice day!


On Wednesday, June 5, 2019 at 9:44:34 AM UTC+2, Marc Monnerat wrote:
Hello Francesco,

The Geoadmin API is very old now and not updated anymore. It is base on OL3 (default) or OL4 (http://api3.geo.admin.ch/loader.js?version=4.4.2) for the latest.
So, It is better to use pure OL. Besides that, I don't think OL4 has client-side reprojection (you can't mix sources of different projections)

Regards,

Marc
Le mar. 4 juin 2019 à 16:28, David Oesch <david...@gmail.com> a écrit :

--
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 geoadm...@googlegroups.com.

Marc Monnerat

unread,
Jun 7, 2019, 12:23:06 PM6/7/19
to geoadmin-api
Hello Francesko,


However, you need to register in order to use the WMTS service: https://shop.swisstopo.admin.ch/en/products/geoservice/swisstopo_geoservices/WMTS_info

Regards,

Marc

To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/dd46d23a-37f5-4b36-b5a5-cbab7fc9120b%40googlegroups.com.

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

heiri...@bluewin.ch

unread,
Jul 18, 2019, 11:50:08 AM7/18/19
to GeoAdmin API
Hello

Is there a documentation available about the "import" function of https://map.geo.admin.ch? Is it possible to display other layers on top of the OSM layer? In the following example ch.bav.haltestellen-oev is covered by the OSM layer:

Many thanks
Heinrich Baur


Am Dienstag, 4. Juni 2019 16:28:16 UTC+2 schrieb David Oesch:

David Oesch

unread,
Jul 18, 2019, 11:53:41 AM7/18/19
to geoadm...@googlegroups.com

To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/97ec0e85-6297-4c31-92b6-9c52d04769b6%40googlegroups.com.

David Oesch

unread,
Jul 18, 2019, 11:59:03 AM7/18/19
to geoadm...@googlegroups.com
Actually what u want is reorder the layer

Instruction 

It's like Photoshop

<heiri...@bluewin.ch> schrieb am Do. 18. Juli 2019 um 17:50:
To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/97ec0e85-6297-4c31-92b6-9c52d04769b6%40googlegroups.com.

heiri...@bluewin.ch

unread,
Jul 19, 2019, 2:27:25 AM7/19/19
to GeoAdmin API
Thank you David
Reordering the layers works. But I would like to preset the order of the layers in a call with parameters, something like
When using it as iframe I hope the final user does not need to reorder the layers.
Unfortunately the documentation https://help.geo.admin.ch/?id=54&lang=en does not describe a parameter to preset the order of the layers.

Am Donnerstag, 18. Juli 2019 17:59:03 UTC+2 schrieb David Oesch:
Actually what u want is reorder the layer

Instruction 

It's like Photoshop

David...@swisstopo.ch

unread,
Jul 19, 2019, 3:04:33 AM7/19/19
to geoadm...@googlegroups.com

If you reorder the layer also the permalink changes --- the  “layers” parameter is key

It is all described in help.geo.admin.ch --- spend a minute reading and you will find almost everything , eg also the description on how to work with permalink https://help.geo.admin.ch/?id=54&lang=en wcih will also work in iframe

To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/cf92acfa-03c5-464b-bf41-3a26f1e946a3%40googlegroups.com.

heiri...@bluewin.ch

unread,
Jul 19, 2019, 4:28:32 AM7/19/19
to GeoAdmin API

Yes, the permalink changes when I reorder the layers. But nevertheless when I call the changed permalink the OSM layer will be on top again.

David...@swisstopo.ch

unread,
Jul 19, 2019, 4:36:52 AM7/19/19
to geoadm...@googlegroups.com

You just found a bug

https://github.com/geoadmin/mf-geoadmin3/issues/4989

 

we will fix this

To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/deb0e7f1-22b6-42ca-87a0-870cc160fa45%40googlegroups.com.

heiri...@bluewin.ch

unread,
Jul 19, 2019, 12:41:43 PM7/19/19
to GeoAdmin API

David Oesch

unread,
Jul 19, 2019, 2:17:11 PM7/19/19
to geoadm...@googlegroups.com
Just updated the ticket with your feedback

To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/b8b8d108-64b5-4240-b903-cb7f0627fe14%40googlegroups.com.

heiri...@bluewin.ch

unread,
Aug 10, 2019, 12:11:52 PM8/10/19
to GeoAdmin API
When I try to create a PDF with the print function from the following link:
then an error message is displayed:

Message.png

and only the public transportation stops without the OSM layer are shown in the PDF. Will it be possible to print external data sets in the future?



Am Freitag, 19. Juli 2019 20:17:11 UTC+2 schrieb David Oesch:
Just updated the ticket with your feedback

Marc Monnerat

unread,
Aug 11, 2019, 9:53:41 AM8/11/19
to geoadmin-api
Hello,

The print server is very capable of printing external resources like KML, WMS or WMTS, as long as it has access to them.
The only issue is that the print server is not capable of reprojecting the source projection. When you import an external source into map.geo.admin.ch, it will ask if the source does support the native projection which is LV95 (EPSG:2056), or reproject them on-the-fly for the ubiquitous EPSG:4326 and EPSG:3857. As this is a client-side trick, these layers won't be printed.



Regards,

Marc



To unsubscribe from this group and stop receiving emails from it, send an email to geoadmin-api...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geoadmin-api/9b016e4e-ceb0-4ff9-a814-56f881ee6e8a%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages