Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Can I have multiple server URLs with OpenLayers.Layer.TMS pointing at the mbtiles.php and my mbtiles file as in https://github.com/bmcbride/PHP-MBTiles-Server?

I have been trying to implement three servers as in this example to get multiple urls: http://openlayers.org/dev/examples/multiserver.html but have had no luck.

My three servers are:

tile1.dendrite.ca
tile2.dendrite.ca
tile3.dendrite.ca

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 = this.map.getResolution();
        var x = Math.round ((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
        var y = Math.round ((this.maxExtent.top - bounds.top) / (res * this.tileSize.h));
        var z = this.map.getZoom();
        return "http://tile1.dendrite.ca/mbtiles.php?db="+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
add comment

2 Answers 2

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
add comment
up vote 1 down vote accepted

A more efficient way to serve mbtiles files is to use Infostreams fork of mbtiles-php found at https://github.com/infostreams/mbtiles-php

I found the best documentation for this at http://blog.thematicmapping.org/2012/11/exploring-mapbox-stack-mbtiles-tilejson.html

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", [
    "http://tile1.dendrite.ca/mbtiles/normaltave06/${z}/${x}/${y}.png",
    "http://tile2.dendrite.ca/mbtiles/normaltave06/${z}/${x}/${y}.png",
    "http://tile3.dendrite.ca/mbtiles/normaltave06/${z}/${x}/${y}.png"
    ], {
        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
add comment

Your Answer

 
discard

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.