Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can I have multiple server URLs with OpenLayers.Layer.TMS pointing at the mbtiles.php and my mbtiles file as in

I have been trying to implement three servers as in this example to get multiple urls: but have had no luck.

My three servers are:

My OpenLayers code is:

var normaltave06 = new OpenLayers.Layer.TMS("June Average Temperature", "mbtiles.php", {
        getURL: normaltave06URL,
        isBaseLayer: false
function normaltave06URL (bounds) {
        var db = "normaltave06.mbtiles";
        var res =;
        var x = Math.round ((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
        var y = Math.round (( - / (res * this.tileSize.h));
        var z =;
        return ""+db+"&z="+z+"&x="+x+"&y="+((1 << z) - y - 1);

This code is working with one server, can anybody suggest a way to return all three servers as the tile source in this example?

share|improve this question

You won't be able to use the normal approach (as you linked to for the multiserver example), since that assumes that tiles are reachable directly.

Instead, you could modify the normaltave06URL example to "spread" its queries for each tile across multiple servers (e.g. some kind of round-robin, or perhaps just random).

If you have local servers and not many local users, this may not be a lot faster though - perhaps the "slowness" you are trying to work around isn't really that the browser can't make enough concurrent connections, but instead its a problem with the server configuration (or some other issue). You could try unpacking the mbtiles file(s), and then with-and-without the normal multiserver approach, see if the speed improves.

share|improve this answer
up vote 1 down vote accepted

A more efficient way to serve mbtiles files is to use Infostreams fork of mbtiles-php found at

I found the best documentation for this at

Instead of using OpenLayers.Layer.TMS, you can use OpenLayers.Layer.XYZ which does allow multiple server URLs and buffering etc. I am finding that I get much better performance.

Here is the code for OpenLayers that I have working:

var normaltave06 = new OpenLayers.Layer.XYZ("June Average Temperature", [
    ], {
        isBaseLayer: false
share|improve this answer
If that solves your problem, can you mark it as answered? – BradHards Mar 18 '13 at 3:12
It only lets you mark that your own question is answered after 24 hours. – CDavis Mar 18 '13 at 16:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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