shiveh / mapir
Offcial Map.ir Laravel package
Installs: 2 313
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 1
Forks: 3
Open Issues: 2
Requires
- guzzlehttp/guzzle: ~6.0
This package is auto-updated.
Last update: 2024-10-29 04:42:17 UTC
README
Official Laravel Package for map.ir
Hi, if you have an account in map.ir, you can use this package for laravel
How to install:
composer require shiveh/mapir
php artisan vendor:publish --tag=mapir
Setup:
Laravel Installation
add this line to your app.php providers:
Shiveh\Mapir\MapirLaravelServiceProvider::class,
and add this line to your app.php aliases:
'Mapir' => Shiveh\Mapir\MapirLaravelFacade::class,
After publish the package files you must open mapir.php in config folder and set the api-key.
Like this:
'webservice-url' => env('MAPIR_WEBSERVICE_URL','https://map.ir'),
'api-key' => env('MAPIR_API_KEY','Your map.ir api key'),
Lumen Installation
add package service provider in bootstrap/app.php.
$app->register(Shiveh\Mapir\MapirLaravelServiceProvider::class);
class_alias(Shiveh\Mapir\MapirLaravelFacade::class, 'Mapir');
copy package config directory vendor/shiveh/mapir/config
to root folder alongside with app directory.
update bootstrap/app.php by adding this line in Register Config Files
section:
$app->configure('mapir');
Making Lumen work with facades by uncommenting this line in bootstrap/app.php.
$app->withFacades();
Note:
you can set the keys in your .env file
like this:
MAPIR_WEBSERVICE_URL=https://map.ir
MAPIR_API_KEY=your api-key
Methods:
Mapir::search():
\Mapir::search(
'ساوجینیا',
Select::POI,
Filter::distance('20km'),
[
"type"=> "Point",
"coordinates"=> [
51.3361930847168,
35.7006311416626
]
]
);
The search method has four arguments.
Text(Required):
This argument is used as a text, which you want to find it's location on map. for example (ساوجینیا)
Select(Optional):
Inorder to apply your search request on specific group of entities.
Select :: POI
To select each of these land effects, first write "Select::" and then the name of the land effects according to the following table:
Filter(Optional):
To filter search results, for example, get results only in Tehran.
Filter :: city ('تهران')
More filter features:
Geographic coordinates(Required):
Use this format for coordinates, inorder to get better result. look for other possible formats in this site geojson.io.
[
"type"=> "Point",
"coordinates"=> [
51.3361930847168,
35.7006311416626
]
]
Mapir::searchAutocomplete()
\Mapir::searchAutocomplete(
'ساوجی',
Select::POI,
Filter::distance('20km'),
[
"type"=> "Point",
"coordinates"=> [
51.3361930847168,
35.7006311416626
]
]
);
The search differs with the search (live search) in the concept of the structure of the search words. When using a normal search, the search algorithm looks for addresses that are exactly the same as the text of the input, while the live search matches some of the information entered with the existing data and suggests the closest and most likely results.
Mapir::reverse()
\Mapir::reverse(35.732634, 51.422571);
The reverse is the conversion of geographic coordinates to text addresses
Mapir::fastReverse()
\Mapir::fastReverse(35.732634, 51.422571);
The difference between these two different types of addressing is in detail and the response speed. In full mode, along with the details of the address, if the coordinates of the location are registered on the map, the registered place name is also returned in the response, while in the fast state of this feature does not exist. The main advantage of fast addressing is its speed, so that its response time is about 20ms, while in a full-time matching mode, this is about 70ms.