PHPackages                             teneleven/geolocator-bundle - 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. teneleven/geolocator-bundle

ActiveSymfony-bundle

teneleven/geolocator-bundle
===========================

Makes your models geo-searchable on a google map

3.1(7y ago)72103[6 issues](https://github.com/teneleven/GeolocatorBundle/issues)MITPHP

Since May 14Pushed 7y ago6 watchersCompare

[ Source](https://github.com/teneleven/GeolocatorBundle)[ Packagist](https://packagist.org/packages/teneleven/geolocator-bundle)[ RSS](/packages/teneleven-geolocator-bundle/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

Teneleven Geolocator Bundle
===========================

[](#teneleven-geolocator-bundle)

This bundle adds the ability to make your models geo-searchable and displayed on a map. Example uses are store locators, apartment finders, nearest bus stops.. any geo-searchable scenario you can dream up.

[![Example](https://camo.githubusercontent.com/675579c90862e80c2cb4a7276ca4d4636fbd847d10a69e714643329a3da35353/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f3632343932312f323139393131332f34333061383233362d393864312d313165332d386339652d3165346161643365616365652e4a5047)](https://camo.githubusercontent.com/675579c90862e80c2cb4a7276ca4d4636fbd847d10a69e714643329a3da35353/68747470733a2f2f662e636c6f75642e6769746875622e636f6d2f6173736574732f3632343932312f323139393131332f34333061383233362d393864312d313165332d386339652d3165346161643365616365652e4a5047)

Out of the box the bundle works with Doctrine ORM, but support for other persistence layers is trivial to implement.

To keep the bundle lean and mean we leverage other great bundles where possible, such as:

- [BazingaGeocoderBundle](http://github.com/willdurand/Geocoder) for the actual geo-coding
- [IvoryGoogleMapBundle](https://github.com/egeloen/IvoryGoogleMapBundle) for elegant google map handling
- [CraueGeoBundle](https://raw2.github.com/craue/CraueGeoBundle) for Doctrine geo distance calculations

Sensitive defaults are automatically prepended but you are encouraged to tap into each bundle's configuration directly.

Installation &amp; Setup
------------------------

[](#installation--setup)

### Download the bundle via [composer](http://getcomposer.org)

[](#download-the-bundle-via-composer)

Require the bundle in your composer.json file:

```
{
    "require": {
        "teneleven/geolocator-bundle": "3.*"
    }
}
```

If you are on Symfony 2, you might prefer to lock to the v2 version:

```
{
    "require": {
        "teneleven/geolocator-bundle": "2.*"
    }
}
```

or run:

```
php composer.phar require teneleven/geolocator-bundle:*
```

in a shell.

### Enable the bundle

[](#enable-the-bundle)

```
// in app/AppKernel.php
public function registerBundles() {
	$bundles = array(
		// ...
		new Teneleven\Bundle\GeolocatorBundle\TenelevenGeolocatorBundle(),
	);
	// ...
}
```

### Configure your models

[](#configure-your-models)

Each model type you want to support requires a configuration entry under a unique alias. This alias is used in routing configuration and command parameters.

```
# in app/config/config.yml
teneleven_geolocator:
    locatables:
        dealer: #this is the alias for your model - name this anything you like
            repository: teneleven_sandbox.repository.dealer #this is the service ID of the repository for this model
            radius: 300 #(optional) default limit for search area (in miles)
            limit: 50 #(optional) limit the number of results
            address_properties: [street, city, state, zip] #these are properties of your model which together make up a geo-coder-friendly address

        #other models configs...
```

### Configure your routes

[](#configure-your-routes)

Below is an example route for the model configured above. It leverages the default controller which comes with the bundle and does not specify a custom template.

```
teneleven_sandbox_dealers:
    path:  /dealers
    defaults: { _controller: teneleven.geolocator.controller:locate, entity: dealer, template: ~ }
```

This routing configuration allows you to expose differently configured locators at different URLs, each with a customized location provider and a custom template, if you so desire.

### Geo-code your models

[](#geo-code-your-models)

To be locatable via this bundle your model classes must implement `Teneleven\Bundle\GeolocatorBundle\Model\GeolocatableInterface`.

Given the above configuration you can now run:

```
php app/console teneleven:geolocator:geocode your-model-alias1 your-model-alias2...
```

to apply geo-coordinates to each model instance. By default this bundle uses the Geocoder Google Maps adapter, but you can configure the Geocoder Bundle either way you like. The `your-model-alias` argument is optional. If you leave it off, all models configured with this bundle will be geo-coded.

### You're done

[](#youre-done)

Your models can now be geo-searched and should appear on the result page. Fire off a search and enjoy the fruits of your labor! Did you know - clicking on a result will highlight the related marker, and clicking on a marker will highlight the related result.. how cool is that?!

Customizing this bundle
-----------------------

[](#customizing-this-bundle)

This bundle is designed to be very flexible and make customizations easy. If you run into a use-case not described here, please open a ticket.

### Customizing the results template

[](#customizing-the-results-template)

The default template in this bundle includes several blocks to easily customize the following areas:

- result list &amp; individual result entries
- popup-window content associated with map markers
- the search form
- the content area above the map

Simply extend this template in your project, override the desired blocks, and specify your new template in the routing configuration (see above). Your template can also specify a layout to be used by setting a `teneleven_geolocator_layout` variable inside the template.

### Customizing the location provider

[](#customizing-the-location-provider)

The location provider houses query logic and handles the search form. If your model search includes custom parameters (other than the search location) you will need to extend the default logic and specify a custom search form. One example use-case would be an apartment-finder which allows filtering and sorting by rent level, in addition to geo-distance.

### Customizing the controller

[](#customizing-the-controller)

Currently the controller is where the map is being built. If you need to customize this functionality for some reason, you can provide your own controller implementation and specify it in the routing configuration.

Commands &amp; Address Extractors
---------------------------------

[](#commands--address-extractors)

The bundle includes one command, `teneleven:geolocator:geocode`, to apply geo-coordinates to your models. By default only models with empty latitude/longitude are processed, but you can customize this by providing your own location provider implementation. You might, for example, want to refresh geo-coordinates on recently updated models, or ones that have NOT been updated in a while. Up to you.

Internally, geo-coordinates are provided by the great [Geocoder](https://github.com/willdurand/Geocoder) library, which requires an address input as string, so we provide an `AddressExtractorInterface` along with a default implementation based on the [PropertyAccess](https://github.com/symfony/PropertyAccess) component. If your address extraction logic goes beyond gluing together model properties, you are free to provide your own implementation.

Tips &amp; Tricks
-----------------

[](#tips--tricks)

- Geocoder throttling - to comply with the terms of geo-coding services, you may want to use a Guzzle adapter with throttling plugin enabled
- Map default settings are configurable via [IvoryGoogleMapBundle configuration](https://github.com/egeloen/IvoryGoogleMapBundle/blob/master/Resources/doc/usage/map.md). For Example, you can set a nice default center/zoom to point at your office: ```
    ivory_google_map:
        map:
            center:
                latitude:  32.726104
                longitude: -117.226081
                no_wrap: true

            zoom: 8

    ```

Contributing
------------

[](#contributing)

We welcome ideas, bug reports, and pull requests. Please submit tickets on this GitHub repository.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance3

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 85.3% 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 ~419 days

Total

4

Last Release

2705d ago

Major Versions

2.0 → 3.02017-02-10

### Community

Maintainers

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

---

Top Contributors

[![Richtermeister](https://avatars.githubusercontent.com/u/624921?v=4)](https://github.com/Richtermeister "Richtermeister (29 commits)")[![MichaelMackus](https://avatars.githubusercontent.com/u/737162?v=4)](https://github.com/MichaelMackus "MichaelMackus (4 commits)")[![djaed](https://avatars.githubusercontent.com/u/6396573?v=4)](https://github.com/djaed "djaed (1 commits)")

---

Tags

maplocatorstore locatorgeo locatorlocation searchgeo search

### Embed Badge

![Health badge](/badges/teneleven-geolocator-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/teneleven-geolocator-bundle/health.svg)](https://phpackages.com/packages/teneleven-geolocator-bundle)
```

###  Alternatives

[ramsey/collection

A PHP library for representing and manipulating collections.

1.2k486.0M69](/packages/ramsey-collection)[phpcollection/phpcollection

General-Purpose Collection Library for PHP

1.0k64.0M34](/packages/phpcollection-phpcollection)[dasprid/enum

PHP 7.1 enum implementation

379146.0M11](/packages/dasprid-enum)[marc-mabe/php-enum

Simple and fast implementation of enumerations with native PHP

49444.8M97](/packages/marc-mabe-php-enum)[aimeos/map

Easy and elegant handling of PHP arrays as array-like collection objects similar to jQuery and Laravel Collections

4.2k412.9k11](/packages/aimeos-map)[spatie/geocoder

Geocoding addresses to coordinates

8404.8M15](/packages/spatie-geocoder)

PHPackages © 2026

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