PHPackages                             yappabe/google-map-form-type-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. yappabe/google-map-form-type-bundle

AbandonedArchivedSymfony-bundle

yappabe/google-map-form-type-bundle
===================================

Set latitude and longitude values on a form using Google Maps

v2.1(7y ago)220.1k↓100%2[1 PRs](https://github.com/yappabe/OhGoogleMapFormTypeBundle/pulls)MITPHPPHP &gt;=5.3.2

Since Jan 16Pushed 7y ago2 watchersCompare

[ Source](https://github.com/yappabe/OhGoogleMapFormTypeBundle)[ Packagist](https://packagist.org/packages/yappabe/google-map-form-type-bundle)[ Docs](https://github.com/ollieLtd/OhGoogleMapFormTypeBundle)[ RSS](/packages/yappabe-google-map-form-type-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (1)Versions (5)Used By (0)

OhGoogleMapFormTypeBundle
=========================

[](#ohgooglemapformtypebundle)

Set latitude and longitude values on a form using Google Maps. The map includes a search field and a current location link. When a pin is placed or dragged on the map, the latitude and longitude fields are updated.

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

[](#installation)

This bundle is compatible with Symfony 2.1. Add the following to your `composer.json`:

```
"oh/google-map-form-type-bundle": "dev-master"

```

Register the bundle in your `app/AppKernel.php`:

```
// app/AppKernel.php
public function registerBundles()
    {
        $bundles = array(
            new Oh\GoogleMapFormTypeBundle\OhGoogleMapFormTypeBundle(),
            // ...
```

You might need to change a couple of options if you are trying to use Symfony 2.0

Add OhGoogleMapFormTypeBundle to assetic

```
# app/config/config.yml
# Assetic Configuration
assetic:
    bundles:        [ 'OhGoogleMapFormTypeBundle' ]

...

 oh_google_map_form_type:
    api_key: "%google_maps_api_key%"
```

Usage
-----

[](#usage)

This bundle contains a new FormType called GoogleMapType which can be used in your forms like so:

```
$builder->add('latlng', 'oh_google_maps');

```

On your model you will have to process the latitude and longitude array

```
// Your model eg, src/My/Location/Entity/MyLocation.php
use Symfony\Component\Validator\Constraints as Assert;
use Oh\GoogleMapFormTypeBundle\Validator\Constraints as OhAssert;

class MyLocation
{
    // ... include your lat and lng fields here

    public function setLatLng($latlng)
    {
        $this->setLat($latlng['lat']);
        $this->setLng($latlng['lng']);
        return $this;
    }

    /**
     * @Assert\NotBlank()
     * @OhAssert\LatLng()
     */
    public function getLatLng()
    {
        return array('lat'=>$this->getLat(),'lng'=>$this->getLng());
    }

}

```

Include the twig template for the layout. It's generally a good idea to overwrite the form template in your own twig template

```
# your config.yml
twig:
    form:
        resources:
            # This uses the default - you can put your own one here
            - 'OhGoogleMapFormTypeBundle:Form:fields.html.twig'

```

If you are intending to override some of the elements in the template then you can do so by extending the default `google_maps.html.twig`. This example adds a callback to the javascript when a new map position is selected.

```
{# your template which is inluded in the config.yml (above)
   eg src/My/Location/Resources/views/Form/fields.html.twig #}
{% extends "OhGoogleMapFormTypeBundle:Form:google_maps.html.twig" %}
{% block oh_google_maps_callback %}

			var oh_google_maps_callback = function(location, gmap){
                // logs to the console your new latitude
				console.log('Your new latitude is: '+location.lat());
			}

{% endblock %}

```

Options
-------

[](#options)

There are a number of options, mostly self-explanatory

```
array(
	'type'           => 'text',  // the types to render the lat and lng fields as
	'options'        => array(), // the options for both the fields
	'lat_options'  => array(),   // the options for just the lat field
	'lng_options' => array(),    // the options for just the lng field
	'lat_name'       => 'lat',   // the name of the lat field
	'lng_name'       => 'lng',   // the name of the lng field
	'map_width'      => '100%',     // the width of the map
	'map_height'     => '300px',     // the height of the map
	'default_lat'    => 51.5,    // the starting position on the map
	'default_lng'    => -0.1245, // the starting position on the map
	'include_jquery' => false,   // jquery needs to be included above the field (ie not at the bottom of the page)
	'include_gmaps_js'=>true     // is this the best place to include the google maps javascript?
)

```

Screenshots
-----------

[](#screenshots)

[Default form](https://www.dropbox.com/s/pvoihkkq74imnk3/location-form-1.png)[Current position](https://www.dropbox.com/s/uhf7fk3mx35j137/location-form-current.png)[Search locations](https://www.dropbox.com/s/qdft149ggyfil0p/location-form-search.png)[LatLng validation](https://www.dropbox.com/s/k0xqku5q2gv2nlo/location-form-validation.png)

Known problems
--------------

[](#known-problems)

Because the form type template includes javascript, there's not yet a way to bunch it all together at the very bottom of the page, so it is included at the bottom of the field. This means that jquery and the javascript plugin in Resources/public/js needs to be included before the field. I'm not sure of a way around this, but I think it's going to be addressed in a later version of the form framework.

Credits
-------

[](#credits)

- Ollie Harridge (ollietb) as main author.

###  Health Score

34

↑

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 62.5% 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 ~828 days

Total

3

Last Release

2792d ago

Major Versions

1.0.0 → v2.02017-01-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/8c305e8c996f940e81295c85a623ea86198cd2dd99cbc41e0c4716a219efb2ee?d=identicon)[Trekels](/maintainers/Trekels)

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

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

![](https://www.gravatar.com/avatar/437a0e572c5b07074aa419e7fd43df8dedb706bea45d11608adc40f4906628c7?d=identicon)[b-franco](/maintainers/b-franco)

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

![](https://www.gravatar.com/avatar/fa9efcd9600c637a9d217b6288b9413247d44eb31fa98c26894efe9122b16ed6?d=identicon)[stijn\_ruts](/maintainers/stijn_ruts)

---

Top Contributors

[![ollietb](https://avatars.githubusercontent.com/u/342090?v=4)](https://github.com/ollietb "ollietb (40 commits)")[![oebabaluba](https://avatars.githubusercontent.com/u/3095916?v=4)](https://github.com/oebabaluba "oebabaluba (4 commits)")[![l3l0](https://avatars.githubusercontent.com/u/209405?v=4)](https://github.com/l3l0 "l3l0 (3 commits)")[![wesleylancel](https://avatars.githubusercontent.com/u/2806404?v=4)](https://github.com/wesleylancel "wesleylancel (2 commits)")[![ner0tic](https://avatars.githubusercontent.com/u/161227?v=4)](https://github.com/ner0tic "ner0tic (2 commits)")[![fabstei](https://avatars.githubusercontent.com/u/1098434?v=4)](https://github.com/fabstei "fabstei (2 commits)")[![rmasters](https://avatars.githubusercontent.com/u/34284?v=4)](https://github.com/rmasters "rmasters (2 commits)")[![wlzch](https://avatars.githubusercontent.com/u/977245?v=4)](https://github.com/wlzch "wlzch (1 commits)")[![aitboudad](https://avatars.githubusercontent.com/u/1753742?v=4)](https://github.com/aitboudad "aitboudad (1 commits)")[![xmon](https://avatars.githubusercontent.com/u/4361296?v=4)](https://github.com/xmon "xmon (1 commits)")[![dnna](https://avatars.githubusercontent.com/u/1296821?v=4)](https://github.com/dnna "dnna (1 commits)")[![JokubasR](https://avatars.githubusercontent.com/u/3471628?v=4)](https://github.com/JokubasR "JokubasR (1 commits)")[![jverdeyen](https://avatars.githubusercontent.com/u/117409?v=4)](https://github.com/jverdeyen "jverdeyen (1 commits)")[![scollado](https://avatars.githubusercontent.com/u/712999?v=4)](https://github.com/scollado "scollado (1 commits)")[![stmichael](https://avatars.githubusercontent.com/u/540306?v=4)](https://github.com/stmichael "stmichael (1 commits)")[![Warxcell](https://avatars.githubusercontent.com/u/3340882?v=4)](https://github.com/Warxcell "Warxcell (1 commits)")

---

Tags

symfonyformgoogle maps

### Embed Badge

![Health badge](/badges/yappabe-google-map-form-type-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/yappabe-google-map-form-type-bundle/health.svg)](https://phpackages.com/packages/yappabe-google-map-form-type-bundle)
```

###  Alternatives

[apy/jsfv-bundle

Symfony2 Javascript Form Validation Bundle with localisation support

92770.4k](/packages/apy-jsfv-bundle)[oh/google-map-form-type-bundle

Set latitude, longitude and address values on a form using Google Maps

16166.9k](/packages/oh-google-map-form-type-bundle)[spiriitlabs/form-filter-bundle

This bundle aim to provide classes to build some form filters and then build a doctrine query from this form filter.

35438.3k6](/packages/spiriitlabs-form-filter-bundle)[isometriks/spam-bundle

Provides spam protection for Symfony forms

46198.5k1](/packages/isometriks-spam-bundle)[ekreative/uuid-extra-bundle

Paramconverter, Normalizer and Form Type for Ramsey Uuid

18168.1k](/packages/ekreative-uuid-extra-bundle)[boekkooi/jquery-validation-bundle

Jquery form validation bundle for symfony 2

2773.9k1](/packages/boekkooi-jquery-validation-bundle)

PHPackages © 2026

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