Contents
The GeoAdmin API allows the integration in web pages of geospatial information provided by the Swiss Confederation.
The GeoAdmin API provides also some REST web services like SwissSearch: geocoding
The GeoAdmin API integrates the ExtJS, GeoExt and OpenLayers libraries. You can use these libraries when you use the GeoAdmin API.
The GeoAdmin Light API allows the integration in web pages of geospatial information provided by the Swiss Confederation.
The GeoAdmin Light API is a light version of GeoAdmin API and contains a subset of the functions of GeoAdmin API.
The GeoAdmin Light API targets the user who want to have only a simple map in their web page.
The GeoAdmin Light API contains the minimum part of the OpenLayers library.
The GeoAdmin Light API contains also CSS code which is less intrusive than the CSS code of the GeoAdmin API.
Terms of use of GeoAdmin Light API are the same like GeoAdmin API.
License of GeoAdmin Light API is BSD and, since ExtJS is not part of it, it can be used completely according to the BSD license.
If you need only a simple map, use the GeoAdmin Light API.
If you want to use only OpenLayers, use the GeoAdmin Light API.
If you want to create a web mapping application, use the GeoAdmin API.
If you want to use ExtJS, GeoExt and OpenLayers, use the GeoAdmin API.
If you want a less intrusive API, use the GeoAdmin Light API.
If you ask us, we’ll simply answer that it depends of your needs ;-)
The GeoAdmin API terms of use are accessible here: http://www.geo.admin.ch/internet/geoportal/de/home/services/geoservices/display_services/api_services/order_form.html
The api.geo.admin.ch source may be distributed with a BSD license. ExtJS provides a license exception (http://extjs.com/products/ux-exception.php) for open source frameworks using ExtJS that allows this license. Practically, this means you can modify and redistribute api.geo.admin.ch without any special requirements. Keep in mind that the same is not true for ExtJS - if you redistribute the source or make any modifications, you are bound to the terms of their license.
From a practical point of view, two solutions can be proposed:
- You accept that everyone can use your code (you still can sell it), then you don’t need to buy an ExtJS license and your code will be BSD.
- You don’t accept that someone uses your code (you can of course sell it), then you need to buy an ExtJS license.
The GeoAdmin API has been tested in the following modern browsers: Firefox 3+, Internet Explorer 7+, Chrome 5+, Safari 4+.
The GeoAdmin API doesn’t support mobile devices. The GeoAdmin Light API does !
The API code is composed of various based libraries. You can access the code of these libraries here: https://api.geo.admin.ch/main/wsgi/lib/
More information about these libraries can be found here:
In order to optimize the size of the library, not all code has been integrated in the GeoAdmin API. If you use a function that is not part of the GeoAdmin API, you’ll need to link the approriate source code yourself. We recommend using JSBuild when you deploy a website in production.
- Developer guide: Developer Guide
- User guide: User Guide
Yes, under http://groups.google.com/group/geoadmin-api Feel free to use it and ask all the questions you want.
Here is a non exhaustive list (don’t hesitate to inform us about your own web site, we would be happy to add it here):
Some layers can’t be freely used. These layers are accessible by the way of swisstopo web access - WMTS documentation
Here is a list of the layers that requires a swisstopo web acesss:
Here is a list of all the freely accessible layers:
| Parameter | Description | Example |
|---|---|---|
| lang | Language of the interface: de, fr, it, rm or en | http://map.geo.admin.ch?lang=rm |
| zoom | Zoom level, from 0 to 13 | http://map.geo.admin.ch?zoom=12 |
| scale | Scale | http://map.geo.admin.ch?scale=100000 |
| Y | easting value (from 450‘000 to 900‘000) | http://map.geo.admin.ch?Y=600000 |
| X | northing value, ranging from 50‘000 to 350‘000 (always smaller than Y) | http://map.geo.admin.ch?X=150000 |
| bgOpacity | Opacity of national map covering the underlaying image (0 to 1) | http://map.geo.admin.ch?bgOpacity=0.1 |
| bgLayer | Base layer: one of ch.swisstopo.pixelkarte-farbe, ch.swisstopo.pixelkarte-farbe or voidLayer | http://map.geo.admin.ch?bgLayer=voidLayer |
| layers | Layer to display, see Which layers are available ? for a complete list KML layers are supported with a || separated list with: KML||kml url WMS layers are supported with a || separated list with: WMS||layer title||wms url||layer name | http://map.geo.admin.ch/?layers=WMS%7C%7CGeothermie%7C%7C http%3A%2F%2Fwms.geo.admin.ch%2F%3F%7C%7Cch.swisstopo.geo logie-geophysik-geothermie,ch.ensi.zonenplan-notfallschut z-kernanlagen,KML%7C%7Chttp%3A%2F%2Fwww.meteoschweiz.admi n.ch%2Fweb%2Fde%2Fklima%2Fmesssysteme%2Fboden%2Fgoogle_ea rth.Par.0007.DownloadFile.ext.tmp%2Fobs.kml |
| layers_opacity | Layers opaciy, should match number of layers (0-1.0) | http://map.geo.admin.ch?layers=ch.swisstopo.hiks-dufour&layers_opacity=0.5 |
| layers_visibility | Toggle the visibility of layers present in the tree | http://map.geo.admin.ch?layers=ch.swisstopo.hiks-dufour&l ayers_visibility=False |
| layers_timestamp | Layers timestamps. Only for WMS and WMTS services. This parameter is only read and is never set. | http://map.geo.admin.ch/?layers=ch.kantone.cadastralwebmap-farbe&layers_timestamp=20120501 |
| selectedNode | Selected node in INSPIRE Catalog tree | http://map.geo.admin.ch/?selectedNode=LT2_3 |
| <layer bod id> | Layer bod id (Which layers are available ?) from which to highlight feature(s) with id | http://map.geo.admin.ch/?ch.bafu.bundesinventare-moorlandschaften=212,213 |
| crosshair | crosshair=<type>, possible type: cross, circle, bowl and point | http://map.geo.admin.ch/?Y=538700&X=165890&zoom=6&crosshair=circle |
| swisssearch | swisssearch=<query string> | http://map.geo.admin.ch/?swisssearch=berges%2037%20payerne |
| swipe_ratio | Value between 0 and 1 defining the relative position of the swipe elements visible in the compare mode | http://map.geo.admin.ch/?swipe_ratio=0.5 |
This has to be setup on the API level, by providing a lang property in the API config object. Only french and german are for now completely supported.
var myapi = new GeoAdmin.API({lang: 'fr'});
The tiles used in the GeoAdmin API are generated by TileCache and are stored according to a RESTful OGC Web Map Tile Service Implementation Standard schema.
The parameters for the tiles are the following:
- Resolution (meters): 4000,3750,3500,3250,3000,2750,2500,2250,2000,1750,1500,1250,1000,750,650,500,250,100,50,20,10,5,2.5,2,1.5,1,0.5,0.25,0.1
- Maximum extent bounding box: 420000,30000,900000,350000
- Coordinate system: EPSG:21781
For practical information on how to use the tiles, see our description of the WMTS service.
The GeoAdmin widgets are independent UI components. They can be used during the development of custom applications.
The philosophy of the GeoExt UX has been followed during the creation of these widgets.
In order to print (means generate a PDF of the map), there is two ways:
- you can setup your own MapFish Print server. With that you have the possibility to define your own template (keep in mind that A4 is the maximum authorized size)
- you configure a proxy on your side. The goal of this proxy is to redirect the requests to the GeoAdmin API print server. All this is documented here: Print with Proxy
The source code of the GeoAdmin API project can be found here: https://svn.bgdi.admin.ch/mf-chsdi/trunk/chsdi/
You can acess this repository with the readonly account (username/password): mapfish-reader/heleeshu
The code of the API is accessible here: https://api.geo.admin.ch/main/wsgi/api/
The code of the GeoAdmin widgets is accessible here: https://api.geo.admin.ch/main/wsgi/GeoAdmin.ux/
The code of the base libraries is accessible here: https://api.geo.admin.ch/main/wsgi/lib/
Yes, localhost can be used to test the developments. In all cases, you have to follow the terms of use: http://www.geo.admin.ch/internet/geoportal/de/home/services/geoservices/display_services/api_services/order_form.html
Instead of calling the GeoAdmin API with:
<script type="text/javascript" src="https://api.geo.admin.ch/loader.js"></script>
Call it with:
<script type="text/javascript" src="https://api.geo.admin.ch/loader.js?mode=debug"></script>
In this case, the api code will be uncompressed and this simplifies the debugging process.
The GeoAdmin Light API can be loaded by calling:
<script type="text/javascript" src="https://api.geo.admin.ch/loader.js?mode=light"></script>
If you want to be in debug mode, then load it with:
<script type="text/javascript" src="https://api.geo.admin.ch/loader.js?mode=light-debug"></script>
In this case, the light api code will be uncompressed and this simplifies the debugging process.
In order to keep the api.js file small, only the subset of OpenLayers needed by GeoAdmin is included. Most missing features are exotic OpenLayers.Format and OpenLayers.Layer groups.
If you really need the full OpenLayers library, you may use instead:
<script type="text/javascript" src="https://api.geo.admin.ch/loader.js?mode=full"></script>
and, the same not compressed:
<script type="text/javascript" src="https://api.geo.admin.ch/loader.js?mode=full-debug"></script>
The GeoAdmin API and the CSS are now loaded with the https://api.geo.admin.ch/loader.js script. Contrary to V1, you don’t need to add other script tag to load the css, for example:
<body>
<script type="text/javascript" src="https://api.geo.admin.ch/loader.js"></script>
</body>
Everything has been done in order to keep a backward compatibility. Nevertheless, the following changes imply to modify the existing code:
- The background opacity parameter bgOpacity is now defined between 0 and 1. Percentage are not allowed anymore.
- Modifications in GeoExt (see http://trac.geoext.org/wiki/Release/1.0/Notes) can have an impact on existing implementation. Typically, the GeoExt.Popup have seen important changes.