PHP code example of cedarmaps / cedarmaps-php-sdk
1. Go to this page and download the library: Download cedarmaps/cedarmaps-php-sdk 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/ */
cedarmaps / cedarmaps-php-sdk example snippets
$apiKey = 'YOUR_API_KEY'
$cedarMaps = new \CedarMaps\CedarMaps($apiKey);
[
[
"address" => "اراضی عباس آباد,مهران,سید خندان,...",
"components" => [
"city" => "تهران",
"country" => "ایران",
"districts" => [
"منطقه 4",
"منطقه 3"
],
"localities" => [
"اراضی عباس آباد",
"مهران",
"سید خندان",
"پاسداران"
],
"province" => "تهران"
],
"id" => 429874,
"location" => [
"bb" => [
"ne" => "35.756689799999997,51.464761500000002",
"sw" => "35.7491463,51.423702800000001"
],
"center" => "35.749155599171999,51.428327751596903"
],
"name" => "همت",
"type" => "expressway"
],
[
"address" => "المهدی",
"components" => [
"city" => "تهران",
"country" => "ایران",
"districts" => [
"منطقه 5"
],
"localities" => [
"المهدی"
],
"province" => "تهران"
],
"id" => 338756,
"location" => [
"bb" => [
"ne" => "35.770861600000003,51.323841700000003",
"sw" => "35.770540400000002,51.323066400000002"
],
"center" => "35.770585227006897,51.323426168064202"
],
"name" => "همت",
"type" => "street"
]
]
[
"address" => "بن بست سروش - زرتشت",
"city" => "تهران",
"components" => [
[
"long_name" => "بن بست سروش",
"short_name" => "بن بست سروش",
"type" => "residential"
],
[
"long_name" => "زرتشت",
"short_name" => "زرتشت",
"type" => "primary"
],
[
"long_name" => "بهجت آباد",
"short_name" => "بهجت آباد",
"type" => "locality"
],
[
"long_name" => "منطقه 6",
"short_name" => "منطقه 6",
"type" => "district"
],
[
"long_name" => "تهران",
"short_name" => "تهران",
"type" => "city"
]
],
"locality" => "بهجت آباد",
"district" => "منطقه 6",
"traffic_zone" => [
"in_central" => true,
"in_evenodd" => true,
"name" => "محدوده طرح ترافیک"
]
]
[
"routes" => [
[
"bbox" => [
51.368587,
35.74982,
51.41652,
35.762383
],
"distance" => 7516.338,
"time" => 500912
]
]
]
[
'instructions' => true
]
[
"routes" => [
[
"bbox" => [
51.36444,
35.76323,
51.365623,
35.76432
],
"distance" => 244.929,
"geometry" => [
"coordinates" => [
[
51.365623,
35.76432
],
[
51.365257,
35.764303
],
[
51.364963,
35.764235
],
[
51.364673,
35.764141
],
[
51.364442,
35.764025
],
[
51.364884,
35.763525
],
[
51.364888,
35.763482
],
[
51.365049,
35.763228
],
[
51.36532,
35.76332
]
],
"type" => "LineString"
],
"time" => 22602
]
]
]
[
"routes" => [
[
"bbox" => [
51.43418,
35.738007,
51.43793,
35.738693
],
"distance" => 570.586,
"geometry" => [
"coordinates" => [
[
51.437536,
35.738675
],
[
51.437901,
35.738695
],
[
51.43793,
35.738142
],
[
51.435609,
35.738006
],
[
51.435563,
35.738689
],
[
51.434183,
35.738635
],
[
51.434204,
35.738048
]
],
"type" => "LineString"
],
"instructions" => [
[
"distance" => 32.977,
"heading" => 86.21,
"interval" => [
0,
1
],
"sign" => 0,
"street_name" => "دهم",
"text" => "تا دهم ادامه دهید",
"time" => 4748
],
[
"distance" => 61.447,
"interval" => [
1,
2
],
"sign" => 2,
"street_name" => "سیبویه",
"text" => " به راست بپیچید به سیبویه",
"time" => 4915
],
[
"distance" => 210.041,
"interval" => [
2,
3
],
"sign" => 2,
"street_name" => "هشتم",
"text" => " به راست بپیچید به هشتم",
"time" => 30245
],
[
"distance" => 76.09,
"interval" => [
3,
4
],
"sign" => 2,
"street_name" => "عربعلی",
"text" => " به راست بپیچید به عربعلی",
"time" => 6085
],
[
"distance" => 124.698,
"interval" => [
4,
5
],
"sign" => -2,
"street_name" => "نهم",
"text" => " به چپ بپیچید به نهم",
"time" => 17956
],
[
"distance" => 65.334,
"interval" => [
5,
6
],
"sign" => -2,
"street_name" => "رهبر",
"text" => " به چپ بپیچید به رهبر",
"time" => 9408
],
[
"distance" => 0.0,
"interval" => [
6,
6
],
"last_heading" => 178.3159250006148,
"sign" => 4,
"street_name" => "",
"text" => "پایان!",
"time" => 0
]
],
"time" => 73357
]
]
]
[
"bounds" => [
44,
24.6,
63.4,
39.8
],
"description" => "CedarMaps covering the whole country of Iran",
"maxzoom" => 17,
"minzoom" => 6,
"name" => "CedarMaps Streets",
"tilejson" => "2.3.0",
"tiles" => [
"https =>//api.cedarmaps.com/v1/tiles/cedarmaps.streets/[z]/[x]/[y].png?access_token=<your access token>"
],
"version" => "2.0"
]
[
'INDEXES' => [
'STREET_INDEX' => 'cedarmaps.streets',
],
'FORWARD_GEOCODE' => [
'TYPE' => [
'LOCALITY' => 'locality',
'ROUNDABOUT' => 'roundabout',
'STREET' => 'street',
'FREEWAY' => 'freeway',
'EXPRESSWAY' => 'expressway',
'BOULEVARD' => 'boulevard',
]
],
];
$ composer