snezhkoigor / map
A development package for all map providers
Installs: 213
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^7.1
- ext-json: *
- guzzlehttp/guzzle: ~6.0
- illuminate/support: 5.0 - 5.8
README
Requirements
- PHP >= 7.1.3
- Laravel >= 5.6
Installation
- Install the package via composer:
composer require snezhkoigor/map
- If you are running Laravel 5.5 (the package will be auto-discovered), skip
this step. Find the
providers
array key inconfig/app.php
and register the Map Service Provider:
// 'providers' => [ Map\Laravel\MapServiceProvider::class, // ];
Providers
By default, the configuration specifies a Chain provider, containing the GoogleMaps provider for addresses as well as reverse lookups with lat/long.
However, you are free to add or remove providers as needed, both inside the Chain provider, as well as along-side it. The following is the default configuration provided by the package:
<?php
use Map\Laravel\Providers\Yandex;
return [
/*
|--------------------------------------------------------------------------
| Providers
|--------------------------------------------------------------------------
|
*/
'providers' => [
Yandex::class => [
'key' => env('YANDEX_ROUTE_KEY', ''),
'proxy' => env('YANDEX_PROXY_IP', null)
]
]
];
Supported Providers
- Yandex
Customization
If you would like to make changes to the default configuration, publish and edit the configuration file:
php artisan vendor:publish --provider="Map\Laravel\MapServiceProvider" --tag="config"
Usage
The service provider initializes the map
service, accessible via the
facade Map::...
or the application helper app('map')->...
.
Build route
$way = app('map')->route(
(new RouteQuery())
->withThroughPoint(new Coordinate(56.991837, 60.477136))
->withThroughPoint(new Coordinate(56.907375, 60.780160))
->withThroughPoint(new Coordinate(58.201698, 68.253762))
);
Result would be Collection of Coordinate class:
{
'provided_by': ...,
'way_points': [
{
latitude:
longitude:
},
{
latitude:
longitude:
},
...
{
latitude:
longitude:
}
]
}
Dumpers
Package provides dumpers that aim to transform a some object in standard formats.
Supported Dumpers
- Keyhole Markup Language (KML). Keyhole Markup Language is an XML notation for expressing geographic annotation and visualization within Internet-based, two-dimensional maps and three-dimensional Earth browsers.
$way = app('map')->route(
(new RouteQuery())
->withThroughPoint(new Coordinate(56.991837, 60.477136))
->withThroughPoint(new Coordinate(56.907375, 60.780160))
->withThroughPoint(new Coordinate(58.201698, 68.253762))
->withAvoidTollsRoads()
);
$kml = (new Kml())->dumpRoute('name', $way)