bluevertex / mapbox-api-laravel
A Laravel 11+ Package for managing Mapbox Datasets and Tilesets
Installs: 1 093
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 5
Open Issues: 1
Requires
- php: >=7.0.0
- illuminate/contracts: ^5.5
- illuminate/support: ^5.5
- jmikola/geojson: ^1.0
- kitetail/zttp: ^0.3.0
Requires (Dev)
- codedungeon/phpunit-result-printer: ^0.4.4
- orchestra/testbench: ~3.5
- phpunit/phpunit: ^6.5
This package is not auto-updated.
Last update: 2024-10-27 05:36:15 UTC
README
A Laravel 5+ Package for managing Mapbox Datasets and Tilesets
This library supports the listing, creation, and deletion of the following types via the Mapbox API:
Installation
Install Via Composer:
composer require bluevertex/mapbox-api-laravel
Laravel 5.5+
The service provider should be automatically registered.
Laravel ≤ 5.4:
// Laravel: config/app.php
BlueVertex\MapBoxAPILaravel\MapBoxAPILaravelServiceProvider::class
// Facade Alias
'Mapbox' => BlueVertex\MapBoxAPILaravel\Facades\Mapbox::class,
Lumen:
// bootstrap/app.php:
$app->register(BlueVertex\MapBoxAPILaravel\MapBoxAPILaravelServiceProvider::class);
$app->withFacades(true, [
'BlueVertex\MapBoxAPILaravel\Facades\Mapbox' => 'Mapbox'
]);
Configuration
Add the following to your .env
file:
MAPBOX_ACCESS_TOKEN=[Your Mapbox Access Token]
MAPBOX_USERNAME=[Your Mapbox Username]
Note: Make sure your Access Token has the proper scope for all the operations you need to perform.
Usage
Datasets
List Datasets:
$list = Mapbox::datasets()->list();
Create Dataset:
$dataset = Mapbox::datasets()->create([
'name' => 'My Dataset',
'description' => 'This is my dataset'
]);
Retrieve Dataset:
$dataset = Mapbox::datasets($datasetID)->get();
Update Dataset:
$dataset = Mapbox::datasets($datasetID)->update([
'name' => 'My Dataset Updated',
'description' => 'This is my latest dataset'
]);
Delete Dataset:
$response = Mapbox::datasets($datasetID)->delete();
List Feature:
$response = Mapbox::datasets($datasetID)->features()->list();
Insert or Update Feature:
$response = Mapbox::datasets($datasetID)->features()->add($feature);
Retrieve Feature:
$response = Mapbox::datasets($datasetID)->features($featureID)->get();
Delete Feature:
$response = Mapbox::datasets($datasetID)->features($featureID)->delete();
Tilesets
List Tilesets:
// Options array is optional
$list = Mapbox::tilesets()->list([
'type' => 'raster',
'visibility' => 'public',
'sortby' => 'modified',
'limit' => 500
]);
Uploads
Get S3 Credentials:
// Returns S3Credentials Object
$response = Mapbox::uploads()->credentials();
Create Upload:
$response = Mapbox::uploads()->create([
'tileset' => '{username}.mytilesetid',
'url' => 'mapbox://datasets/{username}/{dataset}', // Or S3 Bucket URL from S3Credentials Object
'name' => 'Upload Name'
]);
Retrieve Upload Status:
$response = Mapbox::uploads($uploadID)->get();
List Upload Statuses:
$list = Mapbox::uploads()->list();
Delete Upload:
$response = Mapbox::uploads($uploadID)->delete();