1. Go to this page and download the library: Download automapa/map-services library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
automapa / map-services example snippets
use Automapa\MapServices\ApiClient;
use Automapa\MapServices\Config;
$client = new ApiClient(new Config(
key: 'YOUR_API_KEY',
pass: 'YOUR_PASSWORD',
));
$client->session()->generateSession();
$response = $client->geocoder()->geocode(
city: 'Warsaw',
street: 'Domaniewska',
house: '37',
maxResults: 1,
);
$results = $response->data(); // array of results, each with x, y, city, street, ...
$response = $client->geocoder()->geocodemulti(
addresses: [
['city' => 'Warsaw', 'street' => 'Domaniewska', 'house' => '37'],
['city' => 'Kraków', 'street' => 'Floriańska', 'house' => '1'],
],
);
$results = $response->data(); // array of result arrays, one per input address
do {
sleep(5);
$result = $client->speed()->speedReportResult(requestID: $requestID);
$data = $result->data();
} while ($data['progress'] < 1.0);
foreach ($data['overspeedingArray'] as $violation) {
echo $violation['startLocation'] . ' → ' . $violation['endLocation'] . "\n";
echo ' speed: ' . $violation['speedMax'] . ' km/h, limit: ' . $violation['speedLimit'] . " km/h\n";
}
// $data['reportURL'] — link to the full report
// Autocomplete
$client->autocomplete()->search(
query: 'Warsaw',
extra: ['myCustomParam' => 'value'],
);
// Speed (named params override $extra when the same key appears in both)
$client->speed()->speedReport(
objID: 'VEHICLE-001',
objName: 'Van 1',
objGroup: 'Fleet',
points: $points,
extra: ['myCustomParam' => 'value'],
);
// Via service + method name (preferred)
$client->call('Geocoder', 'newMethod', ['param' => 'value']);
// Or via full URL path (fallback)
$client->request('POST', '/v3/Geocoder/newMethod', ['param' => 'value']);
// Native format (default)
$response = $client->geocoder()->geocode(city: 'Kraków');
$data = $response->data(); // API data
$raw = $response->raw(); // full raw response (always available)
// Google format
$response = $client->geocoder()->geocode(city: 'Kraków', extra: ['format' => 'google']);