PHPackages                             cedarmaps/cedarmaps-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. cedarmaps/cedarmaps-php-sdk

ActiveLibrary[API Development](/categories/api)

cedarmaps/cedarmaps-php-sdk
===========================

A PHP Wrapper for CedarMaps API

2.0.5(6y ago)15171MITPHPPHP &gt;=5.6.0CI failing

Since Jul 21Pushed 5y ago2 watchersCompare

[ Source](https://github.com/cedarstudios/cedarmaps-php-sdk)[ Packagist](https://packagist.org/packages/cedarmaps/cedarmaps-php-sdk)[ Docs](https://github.com/sinaabadi/cedarmaps-php-sdk)[ RSS](/packages/cedarmaps-cedarmaps-php-sdk/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (5)Versions (10)Used By (0)

cedar-maps
==========

[](#cedar-maps)

A mapping service and highly detailed and spatially accurate GIS vector data application that covers the whole country of Iran.

Install
-------

[](#install)

```
$ composer require cedarmaps/cedarmaps-php-sdk

```

Getting Started
---------------

[](#getting-started)

### Getting Access Token

[](#getting-access-token)

You should have a `client_id` and `client_secret` in order to get an access\_token.

```
    POST  "https://api.cedarmaps.com/v1/token" with client_id= client_secret=

```

```
$apiKey = 'YOUR_API_KEY'

$cedarMaps = new \CedarMaps\CedarMaps($apiKey);
```

API
---

[](#api)

### \#getForwardGeocoding(query, index, filters)

[](#getforwardgeocodingquery-index-filters)

#### input

[](#input)

query: `string`, URL-encoded text **\[REQUIRED\]**

index: Pick from CedarMaps::Constants\['INDEXES'\] for example CedarMaps::Constants\['INDEXES'\]\['STREET\_INDEX'\]

filters:

ParamTypeDescriptionlimitintegerMax is 30distancefloatUnit is km, 0.1 means 100 meterslocationArray: \['lat' =&gt; &lt;SOME\_LATITUDE&gt;,'lon' =&gt; SOME\_LONGITUDE\]Center point of a nearby search. should be accompanied with distance paramtypeArrayPick from CedarMaps::Constants\['FORWARD\_GEOCODE'\]\['TYPE'\]neArray: \['lat' =&gt; &lt;SOME\_LATITUDE&gt;,'lon' =&gt; SOME\_LONGITUDE\]Specifies north east of the bounding box - should be accompanied with sw paramswArray: \['lat' =&gt; &lt;SOME\_LATITUDE&gt;,'lon' =&gt; SOME\_LONGITUDE\]Specifies south west of the bounding box - should be accompanied with ne param##### Sample Response:

[](#sample-response)

```
[
       [
            "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"
        ]
    ]
```

### \#getReverseGeocoding(lat, lon, index)

[](#getreversegeocodinglat-lon-index)

It gives you an address based on a provided LatLng pair.

#### input

[](#input-1)

lat: `number`, Latitude **\[REQUIRED\]**

long: `number`, Longitude **\[REQUIRED\]**

index: Pick from CedarMaps::Constants\['INDEXES'\] for example CedarMaps::Constants\['INDEXES'\]\['STREET\_INDEX'\]

##### Sample Response:

[](#sample-response-1)

```
[
        "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" =>  "محدوده طرح ترافیک"
        ]
    ]
```

### \#getDistance(points)

[](#getdistancepoints)

This method calculates the distance between points in meters. It can be called with up to 100 different points in a single request.

#### input

[](#input-2)

points: `array`, Array of point Arrays `['lat' => ,'lon' => SOME_LONGITUDE]` **\[REQUIRED\]**

##### Response Elements:

[](#response-elements)

ParamDescriptiondistanceThe overall distance of the route, in metertimeThe overall time of the route, in msbboxThe bounding box of the route, format: minLon, minLat, maxLon, maxLat##### Sample Response:

[](#sample-response-2)

```
[
        "routes" => [
           [
                "bbox" => [
                    51.368587,
                    35.74982,
                    51.41652,
                    35.762383
                ],
                "distance" =>  7516.338,
                "time" =>  500912
            ]
        ]
    ]
```

### \#getDirection(points, options)

[](#getdirectionpoints-options)

This method calculates the optimal driving routes between two or more points.

#### input

[](#input-3)

points: `Array`, `Array: ['lat' => ,'lon' => SOME_LONGITUDE]` **\[REQUIRED\]**

options: `Array of options like ['instructions' => true]` Currently the only option is `instructions` that is `boolean`

**Example**

```
[
  'instructions' => true
]
```

##### Response Elements:

[](#response-elements-1)

ParamDescriptiondistanceThe overall distance of the route, in metertimeThe overall time of the route, in msbboxThe bounding box of the route, format: minLon, minLat, maxLon, maxLatgeometryThe geometry of the route as a GeoJSON LineString##### Sample Response:

[](#sample-response-3)

```
 [
        "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
            ]
        ]
    ]
```

##### Turn-by-turn Navigation

[](#turn-by-turn-navigation)

In order to get turn-by-turn instructions you should include {instructions:true} as option.

Response elements when instructions option provided:

ParamDescriptioninstructionsInstructions for this route. The last instruction is always the Finish instruction and takes 0ms and 0meterinstructions\[\].textA description what the user has to do in order to follow the routeinstructions\[\].street\_nameThe name of the street to turn onto in order to follow the routeinstructions\[\].distanceThe distance for this instruction, in meterinstructions\[\].timeThe duration for this instruction, in msinstructions\[\].intervalAn array containing the first and the last index (relative to geometry.coordinates) of the points for this instruction. This is useful to know for which part of the route the instructions are validinstructions\[\].signA number which specifies the sign to show - Keep Left=-7
- Turn Sharp Left = -3
- Turn Left = -2
- Turn Slight Left = -1
- Continue = 0
- Turn Slight Right = 1
- Turn Right = 2
- Turn Sharp Right = 3
- Reached via = 5
- Roundabout = 6
- Finish = 4

Sample Response when instructions option provided:

```
[
        "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
            ]
        ]
    ]
```

### \#getTileJson(mapId)

[](#gettilejsonmapid)

TileJSON is a format that manages the complexities of custom maps. It organizes zoom levels, center points, legend contents, and more, into a format that makes it easy to display a map.

#### input

[](#input-4)

mapId: `string`, Cedar map ID **\[REQUIRED\]**

##### Sample Response:

[](#sample-response-4)

```
[
    "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="
    ],
    "version" => "2.0"
]
```

### Constants

[](#constants)

```
[
        'INDEXES' => [
            'STREET_INDEX' => 'cedarmaps.streets',
        ],
        'FORWARD_GEOCODE' => [
            'TYPE' => [
                'LOCALITY' => 'locality',
                'ROUNDABOUT' => 'roundabout',
                'STREET' => 'street',
                'FREEWAY' => 'freeway',
                'EXPRESSWAY' => 'expressway',
                'BOULEVARD' => 'boulevard',
            ]
        ],
    ];
```

License
-------

[](#license)

MIT © [Cedar Maps](https://cedarmaps.com)

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 76.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~68 days

Recently: every ~112 days

Total

8

Last Release

2375d ago

Major Versions

1.0.1 → 2.0.02018-08-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2ef71e90bf37ea719075368c585319aa3f6394ee3284c95b29c2b7b6e3f6a00?d=identicon)[cedarmaps](/maintainers/cedarmaps)

![](https://www.gravatar.com/avatar/070b41c55d762ec13bd085178cd9232037095be9f9e2ffb6a3b542077bae48d6?d=identicon)[sinaabadi](/maintainers/sinaabadi)

---

Top Contributors

[![sinaabadi](https://avatars.githubusercontent.com/u/37250396?v=4)](https://github.com/sinaabadi "sinaabadi (20 commits)")[![nimolix](https://avatars.githubusercontent.com/u/235702?v=4)](https://github.com/nimolix "nimolix (5 commits)")[![sadjadteh](https://avatars.githubusercontent.com/u/28616335?v=4)](https://github.com/sadjadteh "sadjadteh (1 commits)")

---

Tags

cedarcedarmapscedarmaps-apidirectiongeocodingnavigationphpmapdistancereverse-geocodingdirectionCedarcedarmaps apiforward geocodingtile json

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cedarmaps-cedarmaps-php-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/cedarmaps-cedarmaps-php-sdk/health.svg)](https://phpackages.com/packages/cedarmaps-cedarmaps-php-sdk)
```

###  Alternatives

[checkout/checkout-sdk-php

Checkout.com SDK for PHP

553.3M7](/packages/checkout-checkout-sdk-php)[mailchimp/transactional

458.9M16](/packages/mailchimp-transactional)[cantie/app-store-connect-api

A PHP client library for accessing App Store Connect APIs

2831.4k](/packages/cantie-app-store-connect-api)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
