{"id":22258417,"url":"https://github.com/t1gor/geocoder","last_synced_at":"2025-03-25T13:14:18.281Z","repository":{"id":7456808,"uuid":"8801406","full_name":"t1gor/geocoder","owner":"t1gor","description":"GeoCoder.php class to get the coords from the adress. All free, limits up to about 7000 requests per day.","archived":false,"fork":false,"pushed_at":"2013-03-15T16:30:48.000Z","size":116,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-01-30T12:13:50.246Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"mrdoob/three.js","license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/t1gor.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":"2013-03-15T14:42:07.000Z","updated_at":"2013-11-05T07:07:51.000Z","dependencies_parsed_at":"2022-08-30T06:51:51.171Z","dependency_job_id":null,"html_url":"https://github.com/t1gor/geocoder","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t1gor%2Fgeocoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t1gor%2Fgeocoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t1gor%2Fgeocoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/t1gor%2Fgeocoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/t1gor","download_url":"https://codeload.github.com/t1gor/geocoder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245467614,"owners_count":20620216,"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":[],"created_at":"2024-12-03T08:16:23.133Z","updated_at":"2025-03-25T13:14:18.256Z","avatar_url":"https://github.com/t1gor.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Free php GeoCoder class\n========\n\nUses 3 API's: \n- [Google](https://developers.google.com/maps/documentation/geocoding/) (2500/day max) \n- [MapQuest](http://developer.mapquest.com/web/products/open/geocoding-service) (seems to be unlimited, but doesn't always find adresses)\n- and [GeoCodeFarm](http://www.geocodefarm.com/geocoding-dashboard.php?reg=1) (2500/day, registration needed)\n\n\nUsage example\n--------------------\n```php\n$coords = GeoCoder::get_coords('Central Park, New York, NY, USA');\n```\n    \nWhere `$coords` is an array like this:\n\n```php\narray(\n    'source'    =\u003e 'google',\n    'lat'\t\t=\u003e 41.6659568,\n    'lng'\t\t=\u003e -80.808452,\n)\n```\n    \nOptionally, you can specify the source API:\n```php\n$coords = GeoCoder::get_coords('Central Park, New York, NY, USA', 'google');\n```\n    \nSource API's are prioritised like this: [Google](https://developers.google.com/maps/documentation/geocoding/), [MapQuest](http://developer.mapquest.com/web/products/open/geocoding-service), [GeoCodeFarm](http://www.geocodefarm.com/geocoding-dashboard.php?reg=1).\n\nSpeeding up\n--------------------\n\nI found it much more efficient with some caching usage. I used - [PHP-SimpleCache](https://github.com/gilbitron/PHP-SimpleCache).\nHere's an axample:\n\n```php\n...\n// load cache class\nrequire_once('SimpleCache.php');\n\n// check if cache\nif ($cache-\u003eis_cached($adress)) {\n\t$geo_data = json_decode($cache-\u003eget_cache($adress));\n\t$geo_data = array(\n\t\t'source'\t=\u003e $geo_data-\u003esource,\n\t\t'lat'\t\t=\u003e $geo_data-\u003elat,\n\t\t'lng'\t\t=\u003e $geo_data-\u003elng,\n\t);\n}\nelse {\n\t// get coords\n\t$geo_data = GeoCoder::get_coords($adress);\n\n\t// cache the response (only if coded ok)\n\tif (is_array($geo_data)) {\n\t\t$cache-\u003eset_cache($adress, json_encode($geo_data));\n\t}\n}\n...\n\n```\n\n\nHave fun!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft1gor%2Fgeocoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft1gor%2Fgeocoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft1gor%2Fgeocoder/lists"}