I would like to add this layer to a site I'm working on that uses leaflet:

The API itself is a javascript file based on OpenLayers: http://api.maps.vic.gov.au/vicmapapi/js/vicmapapi.js (I don't know OpenLayers at all, so I'm not really sure what I'm looking at).

Am I able to access the tiles using leaflet? This didn't work:

var map = L.map('map').setView([-37.3, 145.3], 5);

        var wms = L.tileLayer.wms("http://api.maps.vic.gov.au/vicmapapi/map/wms", {
        FORMAT: 'image/png',
        FIRSTTITLE: false,
        transparent: true,

In particular, it didn't work because the tiles it tried to fetch had URLs like this:


instead of:


The server then returns error messages like "400: (x + width) is outside of Raster". If I increase WIDTH to 10000, then Apache returns 500 Internal Server error with a complaint about Java heap space. Oops.

So - am I barking up the wrong tree here, or is there a way to do this?

  • Try zooming in further. Your bounding box contains huge negative numbers. Set the zoomlevel to eg 10. – johanvdw Sep 3 '13 at 7:36
  • 1
    I think the problem might also be due to the SRS being EPSG:3111. Leaflet generally works with EPSG:3857; I'm not aware of the correct way of setting a LeafLet map in another Spatial reference. – Devdatta Tengshe Sep 3 '13 at 8:10
  • see api.maps.vic.gov.au/vicmapapi/map/wms?request=getcapabilities - as @DevdattaTengshe says the layers are only available as 3111 – Ian Turton Sep 3 '13 at 8:19
  • Thanks. Looks like changing the project in leaflet is possible (blog.kartena.se/…) but won't really help me, as I'd really need to reproject the tiles to match my existing project. – Steve Bennett Sep 4 '13 at 1:17

user1147183 put me on the right track, but I wanted to give a more complete answer.

So, first, yes, Leaflet can access a WMS service, using the TileLayer.WMS subclass.

If the tiles are not available in ESPG 3857 (Web Mercator) then you can either switch your whole leaflet interface to use whatever the WMS service is using (http://blog.kartena.se/local-projections-in-a-world-of-spherical-mercator/), or give up.

In this instance, after I posted the original question, VicMap began providing a separate WMS service in Web Mercator. They don't seem to have documented it anywhere, so thanks user1147183 for providing the URL: /geowebcacheWM/service/wms.

Calling the WMS function getCapabilities (http://api.maps.vic.gov.au/geowebcacheWM/service/wms?request=getcapabilities) shows that there is a layer called WEB_MERCATOR. (Strangely, the layer names bear no relation to those in the EPSG:3111 service, such as CARTOGRAPHICAL).

So, finally you can make this call in leaflet:

var wms = L.tileLayer.wms("http://api.maps.vic.gov.au/geowebcacheWM/service/wms?VERSION=1.1.1&TILED=true", {
                layers: ['WEB_MERCATOR'],
                format: 'image/png',
                transparent: false,
                continuousWorld: true,


The rendering is a little funny, but it's usable.

What it looks like


I am using the same API, just use their Web mercator version. I am making the request as such:

var wms = L.tileLayer.wms("http://api.maps.vic.gov.au/geowebcacheWM/service/wms?VERSION=1.1.1&TILED=true", {
    layers: [layer],
    format: 'image/'+ imgType,
    transparent: choice,

This map is then in 3857, which is the same as Google. Any data then that is in EPSG 4326 can be reprojected on the fly and does not need reprojection, such as GeoJSON. GeoJson by default uses 4326 so using 3111 is inconvenient.

Additional notes:

Note, they may have since changed the web mercator URL, I will update when I have the final one. Also, if you are using their satellite imagery, add the following: height:'512', width:'512' Furthermore, if you are calling the Hybrid or Cartograhic layers you should set the transparent to true because it is a png. The satellite imagery is in JPEG format and thus can be set to false.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.