Download the PHP package bastien-wink/google-map-form-type-bundle without Composer

On this page you can find all versions of the php package bastien-wink/google-map-form-type-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package google-map-form-type-bundle

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

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:

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

Add OhGoogleMapFormTypeBundle to assetic

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 %}
        <script type="text/javascript">
            var oh_google_maps_callback = function(location, gmap){
                // logs to the console your new latitude
                console.log('Your new latitude is: '+location.lat());
            }
        </script>   
{% endblock %}

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
    'addr_options'   => array(), // the options for just the addr field
    'lat_name'       => 'lat',   // the name of the lat field
    'lng_name'       => 'lng',   // the name of the lng field
    'addr_name'      => 'addr',  // the name of the addr field (optional)
    '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

Default form Current position Search locations LatLng validation

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


All versions of google-map-form-type-bundle with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.2
symfony/framework-bundle Version >=2.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package bastien-wink/google-map-form-type-bundle contains the following files

Loading the files please wait ....