PHPackages                             dynamic/silverstripe-geocoder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. dynamic/silverstripe-geocoder

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

dynamic/silverstripe-geocoder
=============================

SilverStripe wrapper for Geocoder

4.0.0(6mo ago)246.2k↓17.3%7[2 issues](https://github.com/dynamic/silverstripe-geocoder/issues)[1 PRs](https://github.com/dynamic/silverstripe-geocoder/pulls)2BSD-3-ClausePHPPHP ^8.1CI passing

Since Oct 1Pushed 6mo ago4 watchersCompare

[ Source](https://github.com/dynamic/silverstripe-geocoder)[ Packagist](https://packagist.org/packages/dynamic/silverstripe-geocoder)[ GitHub Sponsors](https://github.com/sponsors/dynamic)[ RSS](/packages/dynamic-silverstripe-geocoder/feed)WikiDiscussions 4 Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (28)Used By (2)

SilverStripe Geocoder
=====================

[](#silverstripe-geocoder)

SilverStripe wrapper for [Geocoder](https://github.com/geocoder-php/Geocoder)

[![CI](https://github.com/dynamic/silverstripe-geocoder/actions/workflows/ci.yml/badge.svg)](https://github.com/dynamic/silverstripe-geocoder/actions/workflows/ci.yml)[![GitHub Sponsors](https://camo.githubusercontent.com/60ffe799c385149a681602d7d0992a8fe4a1c0315f5063bb8c702d472d5e00a5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73706f6e736f72732f64796e616d69633f6c6162656c3d53706f6e736f7273266c6f676f3d47697448756225323053706f6e736f7273267374796c653d666c617426636f6c6f723d656134616161)](https://github.com/sponsors/dynamic)

[![Latest Stable Version](https://camo.githubusercontent.com/76d7c87fddc71eb8d18c6e345ec981ecf71415ab9a10e630566346f45fa19b59/68747470733a2f2f706f7365722e707567782e6f72672f64796e616d69632f73696c7665727374726970652d67656f636f6465722f762f737461626c65)](https://packagist.org/packages/dynamic/silverstripe-geocoder)[![Total Downloads](https://camo.githubusercontent.com/da5a4e9a83a1cd4477c3db79a18b76200d08dca1a0130668179d375ff86e8648/68747470733a2f2f706f7365722e707567782e6f72672f64796e616d69632f73696c7665727374726970652d67656f636f6465722f646f776e6c6f616473)](https://packagist.org/packages/dynamic/silverstripe-geocoder)[![License](https://camo.githubusercontent.com/dbf7e0297de8911aeaa8679dbfd0c494ac74b0a560fbb0a2318bf931e4c66ce5/68747470733a2f2f706f7365722e707567782e6f72672f64796e616d69632f73696c7665727374726970652d67656f636f6465722f6c6963656e7365)](https://packagist.org/packages/dynamic/silverstripe-geocoder)

Requirements
------------

[](#requirements)

- PHP: ^8.3
- silverstripe/recipe-core: ^6
- dynamic/silverstripe-country-dropdown-field: ^3
- geocoder-php/google-maps-provider: ^4.7
- guzzlehttp/guzzle: ^7.4
- php-http/guzzle7-adapter: ^1.0
- php-http/message: ^1.13

Installation
------------

[](#installation)

`composer require dynamic/silverstripe-geocoder`

Features
--------

[](#features)

- **Address Geocoding**: Automatically convert addresses to latitude/longitude coordinates using Google Maps Geocoding API
- **Address Data Extension**: Adds comprehensive address fields (Address, City, State, PostalCode, Country, Lat, Lng) to any DataObject
- **Distance Calculation**: Calculate and filter DataObjects by distance from a given address
- **Static Map Generation**: Generate static Google Maps images with custom styling and markers
- **Country Dropdown Integration**: Includes country selection field with international support
- **Flexible Configuration**: Disable geocoding per DataObject, customize map styles, and use custom marker icons

License
-------

[](#license)

See [License](license.md)

Example usage
-------------

[](#example-usage)

### Getting Started

[](#getting-started)

in `mysite/_config/config.yml`, apply the DataExtensions to your DataObject:

```
SilverStripe\ORM\DataObject:
  extensions:
    - Dynamic\SilverStripeGeocoder\AddressDataExtension
    - Dynamic\SilverStripeGeocoder\DistanceDataExtension
```

### Google API Keys

[](#google-api-keys)

You'll also need to set two [Google API keys](https://developers.google.com/maps/documentation/javascript/get-api-key). Each key needs to have specific API libraries enabled:

- `geocoder_api_key`
    - Geocoding API
- `map_api_key`
    - Maps JavaScript API
    - Maps Static API

This is primarily due to the restriction rules on Google API keys. The Geocoding key should be tied to the webserver's public IP, while the Maps API needs to be restricted to the website's domain name. Restriction rules help to prevent unauthorized users to use your keys, which can quickly use up your API requests quota.

```
Dynamic\SilverStripeGeocoder\GoogleGeocoder:
  geocoder_api_key: 'your-key-here'
  map_api_key: 'your-key-here'
```

Documentation
-------------

[](#documentation)

### AddressDataExtension

[](#addressdataextension)

The AddressDataExtension adds `Address`, `Address2`, `City`, `State`, `PostalCode`, `Country`, `Lat`, and `Lng` fields. The `Lat` and `Lng` fields are read only in the cms and are automatically generated on write. Geocoding can be disabled on a model basis by setting `disable_geocoding` to true.

```
SilverStripe\ORM\DataObject:
    disable_geocoding: true
```

#### Static Map Image

[](#static-map-image)

Using `$AddressMap` in a template will render the map. `$AddressMap` also has options to easily modify the width, height, and scale of the map. `$AddressMap(320, 240, 1)`

##### Map Style

[](#map-style)

The map can be styled by adding a `mapStyle.json` in any of the following folders in a theme:

```
client/dist/js/
client/dist/javascript/
dist/js/
dist/javascript/
src/javascript/thirdparty
js/
javascript/

```

Styles can be generated using an online service like [Styling Wizard: Google Maps APIs](https://mapstyle.withgoogle.com/)

##### Marker Image

[](#marker-image)

**This does not work on local due to google needing to download the image off the server.**

A custom marker image can be used to match the style of the map in about the same way as the style. An image named `mapIcon` with an extension of `png`, `jpg`, `jpeg`, or `gif` can be put in any of the following folders in a theme:

```
client/dist/img/
client/dist/images/
dist/img/
dist/images/
img/
images/

```

### DistanceDataExtension

[](#distancedataextension)

The DistanceDataExtension should be used in conjunction with the AddressDataExtension. The only time it is viable by itself is if the extended DataObject has `Lat` and `Lng` fields.

The DistanceDataExtension will add a pseudo field for distance away from an address to a DataObject. The address to check the distance to is from the current controller initially. This can be changed by implementing `updateAddressValue($address)` on the DataObject or an extension.

```
/**
 * Always get the distance from Neuschwanstein Castle
 */
public function updateAddressValue(&$address) {
    $address = 'Neuschwansteinstraße 20, 87645 Schwangau, Germany';
}
```

Upgrading from version 3
------------------------

[](#upgrading-from-version-3)

SilverStripe Geocoder v4.0 is compatible with SilverStripe 6. Key changes:

- Updated to SilverStripe CMS 6
- Requires PHP 8.3 or higher
- Updated `dynamic/silverstripe-country-dropdown-field` from ^2 to ^3 (SS6 compatible)
- Internal extension namespace changes (ORM → Core\\Extension); no changes required in user code

For details on the SilverStripe 6 upgrade, see the [SilverStripe 6 upgrade guide](https://docs.silverstripe.org/en/6/changelogs/6.0.0/).

Maintainers
-----------

[](#maintainers)

- [Dynamic](http://www.dynamicagency.com) ()

Bugtracker
----------

[](#bugtracker)

Bugs are tracked in the issues section of this repository. Before submitting an issue please read over existing issues to ensure yours is unique.

If the issue does look like a new bug:

- Create a new issue
- Describe the steps required to reproduce your issue, and the expected outcome. Unit tests, screenshots and screencasts can help here.
- Describe your environment as detailed as possible: SilverStripe version, Browser, PHP version, Operating System, any installed SilverStripe modules.

Please report security issues to the module maintainers directly. Please don't file security issues in the bugtracker.

Development and contribution
----------------------------

[](#development-and-contribution)

If you would like to make contributions to the module please ensure you raise a pull request and discuss with the module maintainers.

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance49

Moderate activity, may be stable

Popularity33

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity82

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 64.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~104 days

Recently: every ~204 days

Total

24

Last Release

181d ago

Major Versions

1.2.x-dev → 2.0.02022-09-16

1.3.1 → 2.0.22022-11-11

2.0.x-dev → 3.0.02023-08-26

3.x-dev → 4.0.02025-11-19

PHP version history (2 changes)4.0.0PHP ^8.1

4.x-devPHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/867942?v=4)[Dynamic](/maintainers/dynamic)[@dynamic](https://github.com/dynamic)

---

Top Contributors

[![jsirish](https://avatars.githubusercontent.com/u/1163643?v=4)](https://github.com/jsirish "jsirish (56 commits)")[![mak001](https://avatars.githubusercontent.com/u/1750550?v=4)](https://github.com/mak001 "mak001 (18 commits)")[![muskie9](https://avatars.githubusercontent.com/u/870751?v=4)](https://github.com/muskie9 "muskie9 (9 commits)")[![korthjp17](https://avatars.githubusercontent.com/u/3858661?v=4)](https://github.com/korthjp17 "korthjp17 (1 commits)")[![hdpero](https://avatars.githubusercontent.com/u/13778690?v=4)](https://github.com/hdpero "hdpero (1 commits)")[![muskie9-opensource](https://avatars.githubusercontent.com/u/113001544?v=4)](https://github.com/muskie9-opensource "muskie9-opensource (1 commits)")[![obj63mc](https://avatars.githubusercontent.com/u/443120?v=4)](https://github.com/obj63mc "obj63mc (1 commits)")

---

Tags

geocoderhacktoberfestsilverstripesilverstripe-geocodergeocodinggeocodersilverstripe

### Embed Badge

![Health badge](/badges/dynamic-silverstripe-geocoder/health.svg)

```
[![Health](https://phpackages.com/badges/dynamic-silverstripe-geocoder/health.svg)](https://phpackages.com/packages/dynamic-silverstripe-geocoder)
```

###  Alternatives

[willdurand/geocoder

Common files for PHP Geocoder

17435.7M159](/packages/willdurand-geocoder)[cheesegrits/filament-google-maps

A Google Maps package for Filament PHP with field, column and widget

322533.2k1](/packages/cheesegrits-filament-google-maps)[symbiote/silverstripe-addressable

SilverStripe addressable and geocoding module

2985.1k7](/packages/symbiote-silverstripe-addressable)[silverstripe/environmentcheck

Provides an API for building environment tests

35503.8k13](/packages/silverstripe-environmentcheck)[jonom/silverstripe-share-care

Social media sharing previews and customisation for Silverstripe

2932.7k1](/packages/jonom-silverstripe-share-care)[demouth/dmgeocoder

Geocoding library.

216.9k](/packages/demouth-dmgeocoder)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
