{"id":23461032,"url":"https://github.com/getkirby/geo","last_synced_at":"2025-07-02T03:31:56.974Z","repository":{"id":62510289,"uuid":"226923030","full_name":"getkirby/geo","owner":"getkirby","description":"Geo Plugin for Kirby CMS","archived":false,"fork":false,"pushed_at":"2025-05-26T11:01:29.000Z","size":44,"stargazers_count":20,"open_issues_count":0,"forks_count":1,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-19T20:03:40.712Z","etag":null,"topics":["cms","geo","kirby","kirby3","kirby4","kirby5","php","plugin"],"latest_commit_sha":null,"homepage":"https://getkirby.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/getkirby.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"custom":["https://getkirby.com/buy"]}},"created_at":"2019-12-09T16:59:41.000Z","updated_at":"2025-05-27T05:58:06.000Z","dependencies_parsed_at":"2025-04-14T05:51:43.100Z","dependency_job_id":"4bd88cda-3e9f-4245-8dc0-b8512baf9d6e","html_url":"https://github.com/getkirby/geo","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/getkirby/geo","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getkirby%2Fgeo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getkirby%2Fgeo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getkirby%2Fgeo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getkirby%2Fgeo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/getkirby","download_url":"https://codeload.github.com/getkirby/geo/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/getkirby%2Fgeo/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260823109,"owners_count":23068284,"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":["cms","geo","kirby","kirby3","kirby4","kirby5","php","plugin"],"created_at":"2024-12-24T07:28:36.251Z","updated_at":"2025-07-02T03:31:56.963Z","avatar_url":"https://github.com/getkirby.png","language":"PHP","funding_links":["https://getkirby.com/buy"],"categories":[],"sub_categories":[],"readme":"# Kirby GEO Plugin\n\nThis plugin adds basic geo search and conversion functionalities to Kirby.\n\n### Supports\n\n- Current releases support Kirby 4 and 5\n- For Kirby 3 support, please use [v1.0.2](https://github.com/getkirby/geo/releases/tag/1.0.2)\n\n## Geo Class Option\n\n### Geo::point($lat, $lng)\n\nCreates a new Kirby Geo Point\n\nExample:\n\n```php\nGeo::point(49.4883333, 8.4647222);\nGeo::point('49.4883333, 8.4647222');\nGeo::point([49.4883333, 8.4647222]);\nGeo::point(['lat' =\u003e 49.4883333, 'lng' =\u003e 8.4647222]);\n```\n\nAfterwards you can get the latitude and longitude values of the point like this:\n\n```php\n$point = Geo::point(49.4883333, 8.4647222);\necho $point-\u003elat();\necho $point-\u003elng();\n```\n\n### Geo::distance($pointA, $pointB)\n\nReturns the distance between two geo points.\n\n```php\n$mannheim = Geo::point(49.4883333, 8.4647222);\n$hamburg  = Geo::point(53.553436, 9.992247);\n\necho 'The distance between Mannheim and Hamburg is: ' . Geo::distance($mannheim, $hamburg);\n```\n\nYou can also return the distance in miles instead of kilometers\n\n```php\necho 'The distance between Mannheim and Hamburg is: ' . Geo::distance($mannheim, $hamburg, 'mi');\n```\n\n### Geo::niceDistance($pointA, $pointB)\n\nReturns the distance between two geo points in a human readable way (i.e. 461.32 km)\n\n```php\n$mannheim = Geo::point(49.4883333, 8.4647222);\n$hamburg  = Geo::point(53.553436, 9.992247);\n\necho 'The distance between Mannheim and Hamburg is: ' . Geo::niceDistance($mannheim, $hamburg);\n```\n\nYou can also return the \"nice distance\" in miles instead of kilometers\n\n```php\necho 'The distance between Mannheim and Hamburg is: ' . Geo::niceDistance($mannheim, $hamburg, 'mi');\n```\n\n### Geo::kilometersToMiles($km)\n\nConverts kilometers into miles:\n\n```php\necho Geo::kilometersToMiles(1000);\n```\n\n### Geo::milesToKilometers($mi)\n\nConverts miles into kilometers:\n\n```php\necho Geo::milesToKilometers(1000);\n```\n\n## Radius Filter\n\nThe plugin automatically adds a new filter for all collections, which can be used to do a radius search:\n\n```php\n$addresses = page('addresses')-\u003echildren()-\u003efilterBy('location', 'radius', [\n  'lat'    =\u003e 49.4883333,\n  'lng'    =\u003e 8.4647222,\n  'radius' =\u003e 10\n]);\n```\n\nTo make this work, the location field for each address page must be in the following format:\n\n```\nlocation: {lat},{lng}\n```\n\nor with a real life example:\n\n```\nlocation: 49.4883333,8.4647222\n```\n\nYou can also filter in miles\n\n```php\n$addresses = page('addresses')-\u003echildren()-\u003efilterBy('location', 'radius', [\n  'lat'    =\u003e 49.4883333,\n  'lng'    =\u003e 8.4647222,\n  'radius' =\u003e 10,\n  'unit'   =\u003e 'mi'\n]);\n```\n\n## Field Methods\n\nThe plugin also adds a set of field methods, which can be handy to work with locations\n\n### $field-\u003ecoordinates()\n\nConverts a field with the value format {lat},{lng} into a valid Kirby Geo Point Object:\n\n```php\n$page-\u003elocation()-\u003ecoordinates()-\u003elat();\n$page-\u003elocation()-\u003ecoordinates()-\u003elng();\n```\n\n### $field-\u003edistance($point)\n\nCalculates the distance between a location field and another Kirby Geo Point:\n\n```php\n$hamburg = Geo::point(53.553436, 9.992247);\n\necho $page-\u003elocation()-\u003edistance($hamburg);\n```\n\nOf course you can run this in miles again:\n\n```php\n$hamburg = Geo::point(53.553436, 9.992247);\n\necho $page-\u003elocation()-\u003edistance($hamburg, 'mi');\n```\n\n### $field-\u003eniceDistance($point)\n\nReturns the distance in a more human friendly format:\n\n```php\n$hamburg = Geo::point(53.553436, 9.992247);\n\necho $page-\u003elocation()-\u003eniceDistance($hamburg);\n```\n\n## What’s Kirby?\n\n- **[getkirby.com](https://getkirby.com)** – Get to know the CMS.\n- **[Try it](https://getkirby.com/try)** – Take a test ride with our online demo. Or download one of our kits to get started.\n- **[Documentation](https://getkirby.com/docs/guide)** – Read the official guide, reference and cookbook recipes.\n- **[Issues](https://github.com/getkirby/kirby/issues)** – Report bugs and other problems.\n- **[Feedback](https://feedback.getkirby.com)** – You have an idea for Kirby? Share it.\n- **[Forum](https://forum.getkirby.com)** – Whenever you get stuck, don't hesitate to reach out for questions and support.\n- **[Discord](https://chat.getkirby.com)** – Hang out and meet the community.\n- **[Mastodon](https://mastodon.social/@getkirby)** – Spread the word.\n- **[Bluesky](https://bsky.app/profile/getkirby.com)** – Spread the word.\n\n---\n\n## License\n\n\u003chttp://www.opensource.org/licenses/mit-license.php\u003e\n\n## Credits\n\n[Bastian Allgeier](https://getkirby.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetkirby%2Fgeo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgetkirby%2Fgeo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgetkirby%2Fgeo/lists"}