{"id":24658543,"url":"https://github.com/cedarstudios/cedarmaps-php-sdk","last_synced_at":"2025-03-21T05:12:58.946Z","repository":{"id":56093035,"uuid":"141791601","full_name":"cedarstudios/cedarmaps-php-sdk","owner":"cedarstudios","description":"Cedarmaps PHP SDK ","archived":false,"fork":false,"pushed_at":"2020-11-25T19:56:28.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-26T01:37:55.078Z","etag":null,"topics":["cedar","cedarmaps","cedarmaps-api","direction","geocoding","navigation"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cedarstudios.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-07-21T07:38:17.000Z","updated_at":"2020-11-25T19:56:30.000Z","dependencies_parsed_at":"2022-08-15T13:00:56.649Z","dependency_job_id":null,"html_url":"https://github.com/cedarstudios/cedarmaps-php-sdk","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedarstudios%2Fcedarmaps-php-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedarstudios%2Fcedarmaps-php-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedarstudios%2Fcedarmaps-php-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cedarstudios%2Fcedarmaps-php-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cedarstudios","download_url":"https://codeload.github.com/cedarstudios/cedarmaps-php-sdk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244739960,"owners_count":20501992,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cedar","cedarmaps","cedarmaps-api","direction","geocoding","navigation"],"created_at":"2025-01-26T01:37:56.643Z","updated_at":"2025-03-21T05:12:58.920Z","avatar_url":"https://github.com/cedarstudios.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cedar-maps\n\nA mapping service and highly detailed and spatially accurate GIS vector data application that covers the whole country of Iran.\n\n\n## Install\n\n```\n$ composer require cedarmaps/cedarmaps-php-sdk\n```\n\n\n## Getting Started\n### Getting Access Token\nYou should have a `client_id` and `client_secret` in order to get an access_token.\n```\n    POST  \"https://api.cedarmaps.com/v1/token\" with client_id=\u003cclient_id\u003e client_secret=\u003cclient_secret\u003e\n```\n\n```php\n\n$apiKey = 'YOUR_API_KEY'\n\n$cedarMaps = new \\CedarMaps\\CedarMaps($apiKey);\n\n```\n\n\n## API\n\n### #getForwardGeocoding(query, index, filters)\n\n#### input\nquery: `string`, URL-encoded text **[REQUIRED]**\n\nindex: Pick from CedarMaps::Constants['INDEXES'] for example CedarMaps::Constants['INDEXES']['STREET_INDEX']\n\nfilters:\n\n| Param | Type | Description |\n| ---- | ---- | ---- |\n| limit | integer | Max is 30 |\n| distance | float | Unit is km, 0.1 means 100 meters |\n| location | Array: ['lat' =\u003e \u003cSOME_LATITUDE\u003e,'lon' =\u003e SOME_LONGITUDE] | Center point of a nearby search. should be accompanied with distance param |\n| type | Array |  Pick from CedarMaps::Constants['FORWARD_GEOCODE']['TYPE']\n| ne | Array: ['lat' =\u003e \u003cSOME_LATITUDE\u003e,'lon' =\u003e SOME_LONGITUDE] | Specifies north east of the bounding box - should be accompanied with sw param |\n| sw | Array: ['lat' =\u003e \u003cSOME_LATITUDE\u003e,'lon' =\u003e SOME_LONGITUDE] | Specifies south west of the bounding box - should be accompanied with ne param |\n\n##### Sample Response:\n\n```php\n[\n       [\n            \"address\" =\u003e \"اراضی عباس آباد,مهران,سید خندان,...\",\n            \"components\" =\u003e [\n                \"city\" =\u003e  \"تهران\",\n                \"country\" =\u003e  \"ایران\",\n                \"districts\" =\u003e [\n                    \"منطقه 4\",\n                    \"منطقه 3\"\n                ],\n                \"localities\" =\u003e [\n                    \"اراضی عباس آباد\",\n                    \"مهران\",\n                    \"سید خندان\",\n                    \"پاسداران\"\n                ],\n                \"province\" =\u003e  \"تهران\"\n            ],\n            \"id\" =\u003e  429874,\n            \"location\" =\u003e [\n                \"bb\" =\u003e [\n                    \"ne\" =\u003e  \"35.756689799999997,51.464761500000002\",\n                    \"sw\" =\u003e  \"35.7491463,51.423702800000001\"\n                ],\n                \"center\" =\u003e  \"35.749155599171999,51.428327751596903\"\n            ],\n            \"name\" =\u003e  \"همت\",\n            \"type\" =\u003e  \"expressway\"\n        ],\n       [\n            \"address\" =\u003e  \"المهدی\",\n            \"components\" =\u003e [\n                \"city\" =\u003e  \"تهران\",\n                \"country\" =\u003e  \"ایران\",\n                \"districts\" =\u003e [\n                    \"منطقه 5\"\n                ],\n                \"localities\" =\u003e [\n                    \"المهدی\"\n                ],\n                \"province\" =\u003e  \"تهران\"\n            ],\n            \"id\" =\u003e  338756,\n            \"location\" =\u003e [\n                \"bb\" =\u003e [\n                    \"ne\" =\u003e  \"35.770861600000003,51.323841700000003\",\n                    \"sw\" =\u003e  \"35.770540400000002,51.323066400000002\"\n                ],\n                \"center\" =\u003e  \"35.770585227006897,51.323426168064202\"\n            ],\n            \"name\" =\u003e  \"همت\",\n            \"type\" =\u003e  \"street\"\n        ]\n    ]\n```\n### #getReverseGeocoding(lat, lon, index)\nIt gives you an address based on a provided LatLng pair.\n#### input\nlat: `number`, Latitude **[REQUIRED]**\n\nlong: `number`, Longitude **[REQUIRED]**\n\nindex: Pick from CedarMaps::Constants['INDEXES'] for example CedarMaps::Constants['INDEXES']['STREET_INDEX']\n\n##### Sample Response:\n\n```php\n[\n        \"address\" =\u003e  \"بن بست سروش - زرتشت\",\n        \"city\" =\u003e  \"تهران\",\n        \"components\" =\u003e [\n           [\n                \"long_name\" =\u003e  \"بن بست سروش\",\n                \"short_name\" =\u003e  \"بن بست سروش\",\n                \"type\" =\u003e  \"residential\"\n            ],\n           [\n                \"long_name\" =\u003e  \"زرتشت\",\n                \"short_name\" =\u003e  \"زرتشت\",\n                \"type\" =\u003e  \"primary\"\n            ],\n           [\n                \"long_name\" =\u003e  \"بهجت آباد\",\n                \"short_name\" =\u003e  \"بهجت آباد\",\n                \"type\" =\u003e  \"locality\"\n            ],\n           [\n                \"long_name\" =\u003e  \"منطقه 6\",\n                \"short_name\" =\u003e  \"منطقه 6\",\n                \"type\" =\u003e  \"district\"\n            ],\n           [\n                \"long_name\" =\u003e  \"تهران\",\n                \"short_name\" =\u003e  \"تهران\",\n                \"type\" =\u003e  \"city\"\n            ]\n        ],\n        \"locality\" =\u003e  \"بهجت آباد\",\n        \"district\" =\u003e  \"منطقه 6\",\n        \"traffic_zone\" =\u003e [\n            \"in_central\" =\u003e  true,\n            \"in_evenodd\" =\u003e  true,\n            \"name\" =\u003e  \"محدوده طرح ترافیک\"\n        ]\n    ]\n```\n\n### #getDistance(points)\nThis method calculates the distance between points in meters. It can be called with up to 100 different points in a single request.\n\n#### input\npoints: `array`, Array of point Arrays `['lat' =\u003e \u003cSOME_LATITUDE\u003e,'lon' =\u003e SOME_LONGITUDE]` **[REQUIRED]**\n\n##### Response Elements:\n\n| Param | Description |\n| ---- | ---- |\n| distance | The overall distance of the route, in meter |\n| time | The overall time of the route, in ms |\n| bbox | The bounding box of the route, format: minLon, minLat, maxLon, maxLat |\n\n\n##### Sample Response:\n\n```php\n[\n        \"routes\" =\u003e [\n           [\n                \"bbox\" =\u003e [\n                    51.368587,\n                    35.74982,\n                    51.41652,\n                    35.762383\n                ],\n                \"distance\" =\u003e  7516.338,\n                \"time\" =\u003e  500912\n            ]\n        ]\n    ]\n```\n\n### #getDirection(points, options)\nThis method calculates the optimal driving routes between two or more points.\n\n#### input\npoints: `Array`, `Array: ['lat' =\u003e \u003cSOME_LATITUDE\u003e,'lon' =\u003e SOME_LONGITUDE]` **[REQUIRED]**\n\noptions: `Array of options like ['instructions' =\u003e true]` Currently the only option is `instructions` that is `boolean`\n\n**Example**\n```php\n[\n  'instructions' =\u003e true\n]\n```\n\n##### Response Elements:\n\n| Param | Description |\n| ---- | ---- |\n| distance | The overall distance of the route, in meter |\n| time | The overall time of the route, in ms |\n| bbox | The bounding box of the route, format: minLon, minLat, maxLon, maxLat |\n| geometry | The geometry of the route as a GeoJSON LineString |\n\n\n##### Sample Response:\n\n```php\n [\n        \"routes\" =\u003e [\n           [\n                \"bbox\" =\u003e [\n                    51.36444,\n                    35.76323,\n                    51.365623,\n                    35.76432\n                ],\n                \"distance\" =\u003e  244.929,\n                \"geometry\" =\u003e [\n                    \"coordinates\" =\u003e [\n                       [\n                            51.365623,\n                            35.76432\n                        ],\n                       [\n                            51.365257,\n                            35.764303\n                        ],\n                       [\n                            51.364963,\n                            35.764235\n                        ],\n                       [\n                            51.364673,\n                            35.764141\n                        ],\n                       [\n                            51.364442,\n                            35.764025\n                        ],\n                       [\n                            51.364884,\n                            35.763525\n                        ],\n                       [\n                            51.364888,\n                            35.763482\n                        ],\n                       [\n                            51.365049,\n                            35.763228\n                        ],\n                       [\n                            51.36532,\n                            35.76332\n                        ]\n                    ],\n                    \"type\" =\u003e  \"LineString\"\n                ],\n                \"time\" =\u003e  22602\n            ]\n        ]\n    ]\n```\n\n##### Turn-by-turn Navigation\n\nIn order to get turn-by-turn instructions you should include {instructions:true} as option.\n\nResponse elements when instructions option provided:\n\n| Param | Description |\n| ---- | ---- |\n| instructions | Instructions for this route. The last instruction is always the Finish instruction and takes 0ms and 0meter |\n| instructions[].text | A description what the user has to do in order to follow the route |\n| instructions[].street_name | The name of the street to turn onto in order to follow the route |\n| instructions[].distance | The distance for this instruction, in meter |\n| instructions[].time | The duration for this instruction, in ms |\n| instructions[].interval | An 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 valid |\n| instructions[].sign | A number which specifies the sign to show \u003cul\u003e\u003cli\u003eKeep Left=-7\u003c/li\u003e \u003cli\u003eTurn Sharp Left = -3\u003c/li\u003e \u003cli\u003eTurn Left = -2\u003c/li\u003e \u003cli\u003eTurn Slight Left = -1\u003c/li\u003e \u003cli\u003eContinue = 0\u003c/li\u003e \u003cli\u003eTurn Slight Right = 1\u003c/li\u003e \u003cli\u003eTurn Right = 2\u003c/li\u003e \u003cli\u003eTurn Sharp Right = 3\u003c/li\u003e \u003cli\u003eReached via = 5\u003c/li\u003e \u003cli\u003eRoundabout = 6\u003c/li\u003e \u003cli\u003eFinish = 4\u003c/li\u003e\u003c/ul\u003e |\n\nSample Response when instructions option provided:\n\n```php\n[\n        \"routes\" =\u003e [\n            [\n                \"bbox\" =\u003e [\n                    51.43418,\n                    35.738007,\n                    51.43793,\n                    35.738693\n                ],\n                \"distance\" =\u003e 570.586,\n                \"geometry\" =\u003e [\n                    \"coordinates\" =\u003e [\n                       [\n                            51.437536,\n                            35.738675\n                        ],\n                       [\n                            51.437901,\n                            35.738695\n                        ],\n                       [\n                            51.43793,\n                            35.738142\n                        ],\n                       [\n                            51.435609,\n                            35.738006\n                        ],\n                       [\n                            51.435563,\n                            35.738689\n                        ],\n                       [\n                            51.434183,\n                            35.738635\n                        ],\n                       [\n                            51.434204,\n                            35.738048\n                        ]\n                    ],\n                    \"type\" =\u003e \"LineString\"\n                ],\n                \"instructions\" =\u003e [\n                    [\n                        \"distance\" =\u003e 32.977,\n                        \"heading\" =\u003e 86.21,\n                        \"interval\" =\u003e [\n                            0,\n                            1\n                        ],\n                        \"sign\" =\u003e 0,\n                        \"street_name\" =\u003e \"دهم\",\n                        \"text\" =\u003e \"تا دهم ادامه دهید\",\n                        \"time\" =\u003e 4748\n                    ],\n                    [\n                        \"distance\" =\u003e 61.447,\n                        \"interval\" =\u003e [\n                            1,\n                            2\n                        ],\n                        \"sign\" =\u003e 2,\n                        \"street_name\" =\u003e \"سیبویه\",\n                        \"text\" =\u003e \" به راست بپیچید به سیبویه\",\n                        \"time\" =\u003e 4915\n                    ],\n                    [\n                        \"distance\" =\u003e 210.041,\n                        \"interval\" =\u003e [\n                            2,\n                            3\n                        ],\n                        \"sign\" =\u003e 2,\n                        \"street_name\" =\u003e \"هشتم\",\n                        \"text\" =\u003e \" به راست بپیچید به هشتم\",\n                        \"time\" =\u003e 30245\n                    ],\n                    [\n                        \"distance\" =\u003e 76.09,\n                        \"interval\" =\u003e [\n                            3,\n                            4\n                        ],\n                        \"sign\" =\u003e 2,\n                        \"street_name\" =\u003e \"عربعلی\",\n                        \"text\" =\u003e \" به راست بپیچید به عربعلی\",\n                        \"time\" =\u003e 6085\n                    ],\n                    [\n                        \"distance\" =\u003e 124.698,\n                        \"interval\" =\u003e [\n                            4,\n                            5\n                        ],\n                        \"sign\" =\u003e -2,\n                        \"street_name\" =\u003e \"نهم\",\n                        \"text\" =\u003e \" به چپ بپیچید به نهم\",\n                        \"time\" =\u003e 17956\n                    ],\n                    [\n                        \"distance\" =\u003e 65.334,\n                        \"interval\" =\u003e [\n                            5,\n                            6\n                        ],\n                        \"sign\" =\u003e -2,\n                        \"street_name\" =\u003e \"رهبر\",\n                        \"text\" =\u003e \" به چپ بپیچید به رهبر\",\n                        \"time\" =\u003e 9408\n                    ],\n                    [\n                        \"distance\" =\u003e 0.0,\n                        \"interval\" =\u003e [\n                            6,\n                            6\n                        ],\n                        \"last_heading\" =\u003e 178.3159250006148,\n                        \"sign\" =\u003e 4,\n                        \"street_name\" =\u003e \"\",\n                        \"text\" =\u003e \"پایان!\",\n                        \"time\" =\u003e 0\n                    ]\n                ],\n                \"time\" =\u003e 73357\n            ]\n        ]\n    ]\n```\n\n\n### #getTileJson(mapId)\nTileJSON 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.\n\n#### input\nmapId: `string`, Cedar map ID  **[REQUIRED]**\n\n\n##### Sample Response:\n\n```php\n[\n    \"bounds\" =\u003e [\n        44,\n        24.6,\n        63.4,\n        39.8\n    ],\n    \"description\" =\u003e \"CedarMaps covering the whole country of Iran\",\n    \"maxzoom\" =\u003e 17,\n    \"minzoom\" =\u003e 6,\n    \"name\" =\u003e \"CedarMaps Streets\",\n    \"tilejson\" =\u003e \"2.3.0\",\n    \"tiles\" =\u003e [\n        \"https =\u003e//api.cedarmaps.com/v1/tiles/cedarmaps.streets/[z]/[x]/[y].png?access_token=\u003cyour access token\u003e\"\n    ],\n    \"version\" =\u003e \"2.0\"\n]\n```\n### Constants\n```php\n[\n        'INDEXES' =\u003e [\n            'STREET_INDEX' =\u003e 'cedarmaps.streets',\n        ],\n        'FORWARD_GEOCODE' =\u003e [\n            'TYPE' =\u003e [\n                'LOCALITY' =\u003e 'locality',\n                'ROUNDABOUT' =\u003e 'roundabout',\n                'STREET' =\u003e 'street',\n                'FREEWAY' =\u003e 'freeway',\n                'EXPRESSWAY' =\u003e 'expressway',\n                'BOULEVARD' =\u003e 'boulevard',\n            ]\n        ],\n    ];\n```\n\n## License\n\nMIT © [Cedar Maps](https://cedarmaps.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedarstudios%2Fcedarmaps-php-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcedarstudios%2Fcedarmaps-php-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcedarstudios%2Fcedarmaps-php-sdk/lists"}