PHPackages                             sunnysideup/silverstripe-googlemapfield - 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. sunnysideup/silverstripe-googlemapfield

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

sunnysideup/silverstripe-googlemapfield
=======================================

Save locations using latitude/longitude DataObject fields.

v2.2.1(7y ago)011BSDPHPPHP &gt;=5.6

Since Jun 30Pushed 1mo agoCompare

[ Source](https://github.com/sunnysideup/silverstripe-googlemapfield)[ Packagist](https://packagist.org/packages/sunnysideup/silverstripe-googlemapfield)[ Docs](http://github.com/BetterBrief/googlemapfield)[ RSS](/packages/sunnysideup-silverstripe-googlemapfield/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (21)Used By (0)

silverstripe-googlemapfield
===========================

[](#silverstripe-googlemapfield)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/14940d3d999d32ac60f0561a1e5c560abb882f29dfed1f37cd9847fcdc8fd320/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f42657474657242726965662f73696c7665727374726970652d676f6f676c656d61706669656c642f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/BetterBrief/silverstripe-googlemapfield/?branch=master)

Lets you record a precise location using latitude/longitude/zoom fields to a DataObject.

Displays a map using the Google Maps API. The user may then choose where to place the marker; the landing coordinates are then saved.

You can also search for locations using the search box, which uses the Google Maps Geocoding API.

Supports SilverStripe 4

Usage
-----

[](#usage)

### Minimal configuration

[](#minimal-configuration)

Given your DataObject uses the field names `Latitude` and `Longitude` for storing the latitude and longitude respectively then the following is a minimal setup to have the map show in the CMS:

```
use SilverStripe\ORM\DataObject;
use BetterBrief\GoogleMapField;

class Store extends DataObject
{
    private static $db = [
        'Title' => 'Varchar(255)',
        'Latitude' => 'Varchar',
        'Longitude' => 'Varchar',
    ];

    public function getCMSFields() {
        $fields = parent::getCMSFiels();

        // add the map field
        $fields->addFieldToTab('Root.Main', new GoogleMapField(
            $this,
            'Location'
        ));

        // remove the lat / lng fields from the CMS
        $fields->removeFieldsFromTab('Root.Main', ['Latitude', 'Longitude']);

        return $fields;
    }
}
```

Remember to set your API key in your site's `config.yml`

```
BetterBrief\GoogleMapField:
  default_options:
    api_key: '[google-api-key]'
```

Optional configuration
----------------------

[](#optional-configuration)

### Configuration options

[](#configuration-options)

You can either set the default options in your yaml file (see [\_config/googlemapfield.yml](_config/googlemapfield.yml)for a complete list) or at run time on each instance of the `GoogleMapField` object.

#### Setting at run time

[](#setting-at-run-time)

To set options at run time pass through an array of options (3rd construct parameter):

```
use BetterBrief\GoogleMapField;

$field = new GoogleMapField(
    $dataObject,
    'FieldName',
    [
        'api_key' => 'my-api-key',
        'show_search_box' => false,
        'map' => [
            'zoom' => 10,
        ],
        ...
    ]
);
```

#### Customising the map appearance

[](#customising-the-map-appearance)

You can customise the map's appearance by passing through settings into the `map` key of the `$options` (shown above). The `map` settings take a literal representation of the [google.maps.MapOptions](https://developers.google.com/maps/documentation/javascript/reference?csw=1#MapOptions)

For example if we wanted to change the map type from a road map to satellite imagery we could do the following:

```
use BetterBrief\GoogleMapField;

$field = new GoogleMapField(
    $object,
    'Location',
    [
        'map' => [
            'mapTypeId' => 'SATELLITE',
        ],
    ]
);
```

Getting an API key
==================

[](#getting-an-api-key)

Google Maps API key
-------------------

[](#google-maps-api-key)

To get a Google Maps JS API key please see [the official docs](https://developers.google.com/maps/documentation/javascript/get-api-key)

Geocoding access - enabling the search box
------------------------------------------

[](#geocoding-access---enabling-the-search-box)

To use the search box to find locations on the map, you'll need to have enabled the Geocoding API as well. Please see [the official docs](https://developers.google.com/maps/documentation/javascript/geocoding#GetStarted)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance61

Regular maintenance activity

Popularity2

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~207 days

Recently: every ~507 days

Total

17

Last Release

1015d ago

Major Versions

1.x-dev → 2.0.0-rc.12017-11-28

v2.2.1 → 5.x-dev2023-07-31

PHP version history (3 changes)v1.2PHP &gt;=5.3.0

2.0.0-rc.1PHP &gt;=5.6

5.x-devPHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/167154?v=4)[Sunny Side Up](/maintainers/sunnysideup)[@sunnysideup](https://github.com/sunnysideup)

---

Top Contributors

[![dhensby](https://avatars.githubusercontent.com/u/563596?v=4)](https://github.com/dhensby "dhensby (45 commits)")[![willmorgan](https://avatars.githubusercontent.com/u/168688?v=4)](https://github.com/willmorgan "willmorgan (9 commits)")[![sunnysideup](https://avatars.githubusercontent.com/u/167154?v=4)](https://github.com/sunnysideup "sunnysideup (4 commits)")[![jedateach](https://avatars.githubusercontent.com/u/1356335?v=4)](https://github.com/jedateach "jedateach (1 commits)")[![MarkMhn](https://avatars.githubusercontent.com/u/911714?v=4)](https://github.com/MarkMhn "MarkMhn (1 commits)")

---

Tags

googlegeolocationsilverstripemapmapsgooglemapfield

### Embed Badge

![Health badge](/badges/sunnysideup-silverstripe-googlemapfield/health.svg)

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

###  Alternatives

[cornford/googlmapper

An easy way to integrate Google Maps with Laravel.

457447.9k4](/packages/cornford-googlmapper)

PHPackages © 2026

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