Skip to content

Overview

The Geo plugin provides geocoding tools, distance queries, and map helpers for CakePHP. It lets you:

  • Geocode locations and IPs and store the resulting coordinates (lat/lng) alongside your records.
  • Reverse-geocode coordinates back into address data.
  • Query geocoded data by distance using custom finders.
  • Display dynamic Google Maps and open-source Leaflet maps.
  • Render JavaScript-free static maps from multiple providers (Geoapify, Mapbox, Stadia, Google).

CakePHP version

This documentation is for the branch that supports CakePHP 5.1+. See the version map for older releases.

How it works

Under the hood the plugin uses the willdurand/geocoder library, so it supports a wide range of providers:

  • 12+ address-based geocoder providers
  • 10+ IP-based geocoder providers

Most of them also support reverse geocoding, and you can always write your own provider on top.

The plugin works across the common database engines:

  • MySQL
  • PostgreSQL
  • SQLite (handy for quick local testing)

The pieces

ConceptResponsibility
Geocoder behaviorGeocodes entity address fields on save and adds distance finders to your table.
Geocoder classLow-level geocoding and reverse geocoding against a configurable provider.
Calculator / Geo calculatorDistance math, coordinate blurring, unit conversion, and central-point calculation.
GeoJSON value objectsLightweight Point, Polygon, Feature, and FeatureCollection types.
Map helpersGoogle Maps, Leaflet, and static-map rendering for your views.
GeocodedAddresses cacheOptional table that caches geocoding API calls to avoid rate limits.

Demo

See the Sandbox examples for live demos of the map helpers and the Geocoder behavior.

Next steps

Released under the MIT License.