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).

Installation covers packages and plugin loading. Getting started renders a map without an API key or database migration. Composer defines supported runtime versions.

How it works ​

The geocoding features use the willdurand/geocoder library, through optional provider packages:

  • address-based geocoder providers
  • IP-based geocoder providers

Reverse-geocoding support depends on the selected provider. Custom providers can implement the plugin interface.

The non-spatial distance finder supports:

  • MySQL
  • PostgreSQL
  • SQLite built with its SQL math functions enabled (ACOS, COS, SIN, RADIANS and PI)

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 reuses geocoding results to reduce repeated API calls.

Demo ​

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

Next steps ​

Released under the MIT License.