mehrdad-dadkhah/open-street-map-api
Composer 安装命令:
composer require mehrdad-dadkhah/open-street-map-api
包简介
Open Street Map (OSM) service to call and get results of APIs
README 文档
README
Open Street Map (OSM) service to call and get results of APIs.
Will add new services in future.
System requirements
only with >=7.0.0
Installation
composer require mehrdad-dadkhah/open-street-map-api
Usage
with coordinates option:
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'
with polyline option:
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);
If you have local osm-backend server, you can change base url by:
$osm->setBaseUrl('http://your-url.local');
Reverse location with osm
$result = $locationService->setBaseUrl('CAN-SET-URL') // it's optional ->setPoint($lat, $long) ->setLanguage('fa') ->reverseLocation();
Geocodeing
use use MehrdadDadkhah\OSM\NominatimSearchPlaceService; . . . $nomiLocationService = new NominatimSearchPlaceService(); $nomiLocationService->setLimit(1) ->enableAddressDetails() ->setSearchQuery($city->name) // name of city ->search();
Self hosted
If you want self host osrm-backend and notinimate can copy and custom docker-compose.yml in docker directory.
Acknowledgments
- Thanks to osrm-backend
Uses:
统计信息
- 总下载量: 2.32k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2019-01-02