PHP code example of mehrdad-dadkhah / open-street-map-api
1. Go to this page and download the library: Download mehrdad-dadkhah/open-street-map-api 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/ */
mehrdad-dadkhah / open-street-map-api example snippets
use MehrdadDadkhah\OSM\OSMRouteService;
$osm = new OSMRouteService;
$osm->addCoordinate(35.6998, 51.3310)
->addCoordinate(35.7581, 51.5087);
echo $osm->getDuration()->getWithUnit(\MehrdadDadkhah\OSM\Types\Duration::MINUTE_UNIT); // or 'minute'
echo $osm->getDistance()->getWithUnit(\MehrdadDadkhah\OSM\Types\Distance::KILOMETER_UNIT); // or 'kilometer'
use MehrdadDadkhah\OSM\OSMRouteService;
$osm = new OSMRouteService;
$osm->setPolyline('ofp_Ik_vpAilAyu@te@g%60E');
echo $osm->getDuration()->getWithUnit(\MehrdadDadkhah\OSM\Types\Duration::MINUTE_UNIT);
echo $osm->getDistance()->getWithUnit(\MehrdadDadkhah\OSM\Types\Distance::KILOMETER_UNIT);
use use MehrdadDadkhah\OSM\NominatimSearchPlaceService;
.
.
.
$nomiLocationService = new NominatimSearchPlaceService();
$nomiLocationService->setLimit(1)
->enableAddressDetails()
->setSearchQuery($city->name) // name of city
->search();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.