PHPackages                             lordsimal/bolt-geolocation-field - 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. lordsimal/bolt-geolocation-field

ActiveBolt-extension[Utility &amp; Helpers](/categories/utility)

lordsimal/bolt-geolocation-field
================================

📝 Bolt Extension to add the Geolocation FieldType

1.1.10(1y ago)1010.3k↓50%5[1 issues](https://github.com/LordSimal/bolt-geolocation-field/issues)MITJavaScriptPHP &gt;=7.2.9

Since Oct 4Pushed 1y ago1 watchersCompare

[ Source](https://github.com/LordSimal/bolt-geolocation-field)[ Packagist](https://packagist.org/packages/lordsimal/bolt-geolocation-field)[ RSS](/packages/lordsimal-bolt-geolocation-field/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (13)Used By (0)

📝 Bolt Geolocation Field Extension
==================================

[](#-bolt-geolocation-field-extension)

 [ ![Total Downloads](https://camo.githubusercontent.com/28203ec02ba17f139fd32acc55f7900579c57d22a3f67ba49c2b9ea9c81a39d6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f4c6f726453696d616c2f626f6c742d67656f6c6f636174696f6e2d6669656c642e7376673f7374796c653d666c61742d737175617265) ](https://packagist.org/packages/LordSimal/bolt-geolocation-field) [ ![Latest Stable Version](https://camo.githubusercontent.com/d2f2f09934c83640f257a1e8224270616c4a6ae79920543eaf9ced5452f01bfc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f4c6f726453696d616c2f626f6c742d67656f6c6f636174696f6e2d6669656c642e7376673f7374796c653d666c61742d737175617265266c6162656c3d737461626c65) ](https://packagist.org/packages/LordSimal/bolt-geolocation-field)

**This Extension was written for BoltCMS 4**

This extension allows you to use fields of `type: geolocation` in your ContentTypes, as defined in `contenttypes.yaml`

```
composer require lordsimal/bolt-geolocation-field
```

After that you will see a new `config/extensions/bolt-geolocation.yaml` file.

**In here you have to insert your Google Maps JS API Key, otherwise the field won't work correctly!**

```
# Settings for Bolt Geolocation Field

default:
  apikey: ""

```

See more about the Google Maps JS API Key bellow.

After that you can create a new field with the fieldtype `geolocation`

```
test:
    name: Test
    singular_name: Test
    fields:
        location:
            type: geolocation
    viewless: false
    taxonomy: [ ]
    locales: ['en', 'nl', 'pt_BR', 'es']
    singleton: true
    icon_many: "fa:home"
    icon_one: "fa:home"

```

Field can have autocompleteOptions key in order to set componentRestrictions for exemple

```
location:
    type: geolocation
    autocompleteOptions:
        componentRestrictions:
            country: 'us'

```

To see all options avalible, please refer you to [google documentation](https://developers.google.com/maps/documentation/javascript/geocoding#ComponentFiltering)

With that you can see the field in the backend:

[![Backend Field](screenshots/backend-field-empty.png)](screenshots/backend-field-empty.png)

You can search for places by selecting `Search` and then typing your desired place

[![Place Search](screenshots/backend-search.gif)](screenshots/backend-search.gif)

Or if you have Latitude and Longitude of your location you can input that via the `Latitude & Longitude` area.

[![Place Search](screenshots/backend-latlong.gif)](screenshots/backend-latlong.gif)

As you can see in the GIF you need to click the `Update Google Map` button when inputting manual Latitude and Longitude.

You can also set the zoom level as you desire

[![Place Search](screenshots/backend-zoom.gif)](screenshots/backend-zoom.gif)

Google Map API Key
------------------

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

If you don't already have an API key go to and create a new project.

After that you have to enable the following API's for this project:

- **Maps JavaScript API**
    - This is needed to create Google Maps via JS
- **Places API**
    - This is needed to have a nice search behaviour when your searching for places

After that you need to create an API Key via the **Credentials** Menu.

I would recommend you to restrict this key at least by **HTTP referrers** so only your website can use the API key.

This now generated API key needs to be inserted into your `config/extensions/bolt-geolocation.yaml` file.

Finally you will need to create a **Billing Account** under  **AND** link it to your previously created API Console project
[https://cloud.google.com/billing/docs/how-to/modify-project#confirm\_billing\_is\_enabled\_on\_a\_project](https://cloud.google.com/billing/docs/how-to/modify-project#confirm_billing_is_enabled_on_a_project)

Google requires you to insert one, otherwise it won't work as desired.

See for more information.

Why did I choose Google Map JS API instead of an embeded version?
-----------------------------------------------------------------

[](#why-did-i-choose-google-map-js-api-instead-of-an-embeded-version)

Trust me, I tried to implement this without the need of an API key.

But unfortunately Google only allows 1 iFrame per page to be loaded.

Therefore you can't have multiple fields defined as `type: geolocation` because only the first one works and all the others won't.

And since there is (as far as I know) no Map Provider out there, which allows multiple embeded Maps without an API key I have chosen the most popular one.

Accessing the values in the frontend
------------------------------------

[](#accessing-the-values-in-the-frontend)

Basically everything in the filed is saved inside a JSON.

BoltCMS returns that JSON as a string, therefore we have to decode it first.

```
{% set field_value = record.location %}

{% if field_value is not json %}
  The given field value for {{ record.location.name }} is not a valid json
{% else %}
  {% set location_json = record.location|json_decode() %}

  Selected: {{ location_json.selected }}
  Zoom: {{ location_json.zoom }}
  Search: {{ location_json.search }}
  Latitude: {{ location_json.lat }}
  Longitude: {{ location_json.long }}
{% endif %}

```

- **Record** here is the current entry for the content type.
- **location** is the name you have given the filed in the contenttypes.yaml
- **location\_json.selected** is either **search** or **latlong**
- **location\_json.zoom** is a value between 0 and 19
- **location\_json.search** is the searchterm aka the searched location
- **location\_json.lat** is the latitude value
- **location\_json.long** is the longitude value

### Outputting a simple embedded map with an iframe

[](#outputting-a-simple-embedded-map-with-an-iframe)

If you don't want to output the map yourself with the Google Map JS API you can use the data from above to output an embedded map via an `iframe`

```
{% set field_value = record.location %}

{% if field_value is not json %}
  The given field value for {{ record.location.name }} is not a valid json
{% else %}
  {% set location_json = record.location|json_decode() %}

  {% if location_json.selected == "search" %}
    {% set gmap_query = location_json.search|url_encode %}
  {% elseif location_json.selected == "latlong" %}
    {% set gmap_query = location_json.lat ~ ',' ~ location_json.long %}
  {% endif %}

{% endif %}

```

I would recommend to you to set the following CSS in your application as well:

```
.geolocation-field-iframe {
    height: 500px; /* or what height you need */
    width: 100%;
}
.geolocation-field-iframe {
    height: 100%;
    width: 100%;
}
```

> **WARNING**: Google only allows 1 iFrame per URL. See

Therefore if you need to output multiple maps on one page you will need to implement the Google Maps JS API for yourself in your frontend.

Running PHPStan and Easy Codings Standard
-----------------------------------------

[](#running-phpstan-and-easy-codings-standard)

First, make sure dependencies are installed:

```
COMPOSER_MEMORY_LIMIT=-1 composer update

```

And then run ECS:

```
vendor/bin/ecs check src

```

###  Health Score

37

—

LowBetter than 82% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity31

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 61.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 ~128 days

Recently: every ~211 days

Total

12

Last Release

632d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bfa3748cb4e1bf824128dc4b23bce7f80654dd560a002048c89c567ef67c0928?d=identicon)[LordSimal](/maintainers/LordSimal)

---

Top Contributors

[![LordSimal](https://avatars.githubusercontent.com/u/9105243?v=4)](https://github.com/LordSimal "LordSimal (27 commits)")[![Fredxd](https://avatars.githubusercontent.com/u/4354248?v=4)](https://github.com/Fredxd "Fredxd (5 commits)")[![ashceo](https://avatars.githubusercontent.com/u/49865434?v=4)](https://github.com/ashceo "ashceo (4 commits)")[![bobdenotter](https://avatars.githubusercontent.com/u/1833361?v=4)](https://github.com/bobdenotter "bobdenotter (3 commits)")[![drkNsubuga](https://avatars.githubusercontent.com/u/12871099?v=4)](https://github.com/drkNsubuga "drkNsubuga (2 commits)")[![Spomsoree](https://avatars.githubusercontent.com/u/14187981?v=4)](https://github.com/Spomsoree "Spomsoree (2 commits)")[![I-Valchev](https://avatars.githubusercontent.com/u/7093518?v=4)](https://github.com/I-Valchev "I-Valchev (1 commits)")

---

Tags

boltcmsextension

###  Code Quality

Code StyleECS

### Embed Badge

![Health badge](/badges/lordsimal-bolt-geolocation-field/health.svg)

```
[![Health](https://phpackages.com/badges/lordsimal-bolt-geolocation-field/health.svg)](https://phpackages.com/packages/lordsimal-bolt-geolocation-field)
```

###  Alternatives

[tzookb/tbmsg

users messaging system

10917.1k](/packages/tzookb-tbmsg)[cyber-duck/silverstripe-seo

A SilverStripe module to optimise the Meta, crawling, indexing, and sharing of your website content

4351.1k](/packages/cyber-duck-silverstripe-seo)[alexandresalome/assetic-extra-bundle

Extra feature for Assetic (asset directory)

1811.4k](/packages/alexandresalome-assetic-extra-bundle)

PHPackages © 2026

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