Swisstopo maps as overlay with Google Maps API

464 views
Skip to first unread message

Martin Weggler

unread,
Feb 16, 2015, 9:00:50 AM2/16/15
to geoadm...@googlegroups.com
Hi

I got several Google Map APIs displaying swisstopo pixel maps as an option. All these maps are not displaying ( no error notice  in console ) since ca. Feb. 11, 2015. Any suggestions what I missed? Examples for swisstopo as overlay on a Google Map API welcomed.

Thank! Martin

Used code:

 
       var PixelkarteType = new google.maps.ImageMapType({


            isPng
:         true,
            maxZoom
:     20,
            minZoom
:     7,
            opacity
:    0.8,
            name
:         "Landeskarte",
            tileSize
:     new google.maps.Size(256, 256),
            credit
:     'swisstopo',
            getTileUrl
: function(coord, zoom) {
               
var config = {
                    service
: "http://proxy-wxs.ign.fr/url/http:/api.geo.admin.ch/main/mapproxy/service?",
                    layers
: "ch.swisstopo.pixelkarte-farbe",
                    extension
: "jpeg"
               
};
               
var url = WMSGetTileUrl(coord, zoom, config);
               
return url;
           
}
       
});

       
function WMSGetTileUrl(coord, zoom, config) {
           
var proj = map.getProjection();
           
var zfactor = Math.pow(2, zoom);
           
var top = proj.fromPointToLatLng(new google.maps.Point(coord.x * 256 / zfactor, coord.y * 256 / zfactor));
           
var bot = proj.fromPointToLatLng(new google.maps.Point((coord.x + 1) * 256 / zfactor, (coord.y + 1) * 256 / zfactor));

           
var bbox = top.lng() + "," + bot.lat() + "," + bot.lng() + "," + top.lat();

           
var url = config.service + "LAYERS={0}&FORMAT=image/{1}&SRS=EPSG:4326&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap" + "&STYLES=&BBOX={2}&WIDTH=256&HEIGHT=256";
            url
= url.format(config.layers, config.extension, bbox);

           
return url;
       
}

Marc Monnerat

unread,
Feb 16, 2015, 12:48:11 PM2/16/15
to geoadmin-api
Hello Martin,

Bad and good news...

The bad news is the old api (http://api.geo.admin.ch) has been shut down last week. So everything http://api.geo.admin.ch is now dead.

The good news is that in the new  geo.admin.ch API (http://api3.geo.admin.ch, with a '3'), we  now offers a reprojection service. You don't have to go through the French API

You may have a look at the documentation and you try my example:


Cheers,

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.
For more options, visit https://groups.google.com/d/optout.



--
-- Τα πάντα ῥεῖ καὶ οὐδὲν μένει

Martin Weggler

unread,
Feb 17, 2015, 6:59:31 AM2/17/15
to geoadm...@googlegroups.com
Hi Marc. Work perfectly again.

Cédric MOULLET

unread,
Feb 17, 2015, 7:01:58 AM2/17/15
to geoadm...@googlegroups.com
Hello,
If you want to use the tiles of the swiss federal spatial infrastructure, you need to register to the swisstopo web acccess WMTS http://www.swisstopo.admin.ch/internet/swisstopo/en/home/products/services/web_services/webaccess.html 
It's not allowed to use an external proxy to access the tiles, or do you have a specific agreement with IGN ?
Best regards,
Cédric

--
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.
Reply all
Reply to author
Forward
0 new messages