[GIS] PHP-MBTiles Server implementation with Leaflet and Wax

leafletmbtilesPHP

Using PHP tile server from infostreams with Leaflet and Wax Connector for Leaflet to visualize my .mbtiles. I upped the source and the .mbtiles on a free hosting service.

I am getting a blank Leaflet container on my site right now. There are the zoom buttons and Leaflet attribution but no map.

When I point the browser to domain.com/tiles/tileserver.php it gives the open_basedir restriction error.
When I replace the .json URL (in java.js) with another map's .json that is uploaded on MapBox Hosting, that map shows (interactivity doesn't work though).

EDIT: Since I'm on a free hosting service, I cannot access the httpd.conf or php.ini file. Therefore I have no way of suppressing the open_basedir error. I could use another free hosting service of your choice.

Server directory looks like:

DIR tiles
DIR wax
.htaccess
index.html
java.js
css.css

index.html goes:

<!DOCTYPE html>
<html>
<head>

<script src='wax/ext/leaflet.js' type='text/javascript'></script>
<script src='wax/dist/wax.leaf.js' type='text/javascript'></script>
<link href='wax/ext/leaflet.css' rel='stylesheet' type='text/css' />
<link href='css.css' rel='stylesheet' type='text/css' />
</head>

<body>

<div id="map-div"></div>

<script src="java.js" type='text/javascript'></script>


</body>
</html>     

java.js goes:

var url = "/tiles/Century.json"
wax.tilejson(url, function(tilejson) {

// Create map and add image tiles
var map = new L.Map('map-div')
    .addLayer(new wax.leaf.connector(tilejson))
    .setView(new L.LatLng(51, 0), 1);

// Create map legend
wax.leaf.legend(map, tilejson).appendTo(map._container);

// Add map interaction (tooltips)
wax.leaf.interaction()
    .map(map)
    .tilejson(tilejson)
    .on(wax.tooltip().animate(true).parent(map._container).events());

});

"tiles" directory:

.htaccess
Century.mbtiles   //This is just what I downloaded from infostreams' tile server.
tileserver.php

Best Answer

You may try this project instead:

https://github.com/klokantech/tileserver-php/

It is easier to install, tested on several free web hosting providers, it can run also without .htaccess (if really required) and there are sample viewers (Leaflet, OpenLayers, OL3, Google Maps API, etc) presenting a copy&paste ready JavaScript source code for how to use the tiles in your web application.

The server supports also OGC WMTS - so the maps can be opened in QGIS or ArcGIS for Desktop.

Here is a live demo: http://tileserver.maptiler.com/