Downloads
Stars
Version
This is a small package that allows your Laravel application to provide an XYZ tile server using .mbtiles datasets as the source. It was inspired by maptiler/tileserver-php, which was helpful for understanding the minimum requirements, but is kind of a mess and not something you'd want to drop into an existing project.
However, this package is built for our particular use case and is not as full-featured as the one linked above. It only handles .mbtiles files and metadata validation is less robust because we have more control over the creation of the source data. It might be expanded in the future if our needs change. But if you just want to serve your own mbtiles as a vector layer for Mapbox or something, feel free to give it a shot!
You can use Tippecanoe from Mapbox to create your own mbtiles datasets from GeoJSON, CSV, and other file formats.
Various mapping libraries allow you to add custom layers. Consult the appropriate documentation to learn how each one handles them.
You can install the package via composer:
composer require teamzac/laravel-tileserver
It requires Laravel 8+.
The package is pretty simple to use. The service provider is auto-discovered. You can publish the config file or simply override the three settings (see below) with environment variables.
Then, simply register the routes in a routes file or RouteServiceProvider:
Route::tileserver();
If you'd like to wrap certain middlware around the routes, such as authentication middleware, you can do so:
Route::middleware('auth')->group(function() {
Route::tileserver();
});
This will expose two routes to your app (or three, if you choose):
This is the tile template you can use in your custom map layers.
This is a JSON endpoint that returns the metadata for all available tilesets. You can choose whether to hide this route in the config file.
You can also expose this route to provide a JSON endpoint showing all available tilesets. By default, this is turned off. See the Configuration section for more details.
Three configuration settings are provided:
You can set all of these via environment variables, or publish the config file and manage them there.
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.