Skip to content
This repository has been archived by the owner on Aug 10, 2020. It is now read-only.


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


This module allows you to show location of the address on map (Google Maps), and store it’s coordinates it in distinct field with custom format.


Parameter Type Description
fields* jQuery Form fields from which address is build. Final address is made by concatenation of fields, divided by comma.
container* jQuery Div element where the map will be placed.
coordinates* jQuery Form field in which coordinates will be placed. If in the moment of initialisation this field is not empty, coordinates will be marked on the map with marker.
format string Data format in which coordinates will be stored in the text field. By default it is lng lat, where lat is latitude and lng is longitude. Such data format allows us to prepare field for storing in the database like POINT object: PointFromText('POINT(".$coordinates.")').
center google.maps.LatLng|Array Coordinates of the map center. Used if on the initialisation moment all address fields and coordinates fields are empty.
selectValue boolean By default module takes select values not by val() method, because in common cases tag option in value attribute contains some identifiers, but not values. For example option value=“1”>Russia. Setting this parameter to false cancels this behaviour.
zooms object Levels of scale.
  • initial (initial),
  • country (country precision),
  • locality (city precision),
  • route (street precision),
  • street_address (appartment precision).
marker object Object of marker parameters (Google Maps API).
map object Object of map parameters (Google Maps API).


Method Return value Description
getMap() google.maps.Map Returns map object.
getMarker() google.maps.Marker|null Returns marker object (if marker doesn’t exist return null).
getPosition() google.maps.LatLng|null Return lat and lng object or null.
getPoint(format) string Return coordinates of found address in specified data type. If optional parameter format is not defined, coordinates will be formed according to initialisation options. Can be an empty string if marker doesn’t exist.


Event Descroption
viewchange Event fires on map view change(scale or centering). Manual map moving is not considered.
coordschange Event fires after defining/changing coordinates of current place. Event has options marker and position.
geocodingstart Event fires on geocoding start, which also fires after address fields values change. Event has option address.
geocodingend Event fires when geocoding process is finished. Event has options address and contains properties status and results.

Event properties

Property Type Event Description
map google.maps.Map all events Instance of google.maps.Map
mapCenter google.maps.LatLng all events Instance of google.maps.LatLng
mapZoom integer all events Current level of scale
marker google.maps.Marker|null coordschange Instance of google.maps.Marker or null
position google.maps.LatLng|null coordschange Instance of google.maps.LatLng or null
address string geocodingstart, geocodingend Address for started or finished geocoding process.
status string geocodingend Status of geocoding process. Matches property status of google.maps.Geocoder object.
results object geocodingend Result of geocoding process. Matches property results of google.maps.Geocoder object.

Loading examples

You can get module code via three ways:

  • copy code from repository to your project
  • get code from CDN:
<script type="text/javascript" src="//"></script>
<script type="text/javascript" src="//"></script>
<!-- project page on -->
  • install module via Bower:
bower install coordinates-picker

Project structure:

├── assets
│   ├── images
│   │   └── marker.png
│   └── scripts
│       ├── amd
│       │   ├── main.js
│       │   ├── require.config.js
│       │   └── requirejs.async.js
│       ├── CoordinatesPicker.js
│       └── main.js
└── index.php

Module has dependency of jQuery and Google Maps, and implement AMD loading. Thats why module can be loaded via two ways:

Regular way

Part of index.html file

<script type="text/javascript" src="//"></script>
<script type="text/javascript" src="//;language=ru"></script>
<script type="text/javascript" src="/assets/scripts/CoordinatesPicker.js"></script>
<script type="text/javascript" src="/assets/scripts/main.js"></script>

AMD (using RequireJS)

Part of index.html file

<script data-main="/assets/scripts/amd/main" src="//"></script>
<script src="/assets/scripts/amd/require.config.js"></script>

File /assets/scripts/amd/require.config.js

    paths: {
        async: 'requirejs.async',
        coordinatespicker: '../CoordinatesPicker',
        jquery: '//',
        googlemaps: ';language=ru'

define('googlemaps', ['async!googlemaps'], function() {

Part of /assets/scripts/amd/main.js file

require(['jquery', 'googlemaps', 'coordinatespicker'], function($, google, coordinatesPicker) {
    // look "Usage example"

Usage example

Part of index.html file

<form id="institution-form">
    <select id="country" name="country" class="address-part">
        <option value="">Country</option>
        <option value="1">Russia</option>
        <option value="2">USA</option>
        <option value="3">Poland</option>
        <option value="4">Kazakhstan</option>
        <option value="5">Mongolia</option>
    <input type="text" id="city" name="city" class="address-part" placeholder="City"/>
    <input type="text" id="street" name="street" class="address-part" placeholder="Street"/>
    <input type="text" id="house" name="house" class="address-part" placeholder="Apartment"/>
    <input type="text" id="coordinates" name="coordinates" readonly/>

    <div style="width: 500px; height: 500px;"></div>

Using module in /assets/scripts/main.js or /assets/scripts/amd/main.js file

// If you are using AMD, you must replace BarinBritva.CoordinatesPicker with name 
// given in dependency. In this example it is coordinatesPicker.
var coordinatesPicker = new BarinBritva.CoordinatesPicker({
    fields: $('.address-part'),
    container: $('#map'),
    coordinates: $('#coordinates'),
    format: 'lng,lat',
    center: new google.maps.LatLng(53.517, 49.417),
    zooms: {
        initial: 9,
        country: 11,
        locality: 14,
        route: 16,
        street_address: 18
    marker: {
        draggable: true,
        animation: null,
        icon: '/assets/images/marker.png'
    map: {
        disableDefaultUI: false


You can see demo example <a href="" target=“_blank">in here.


This module allows you to show location of the address on map (Google Maps), and store it’s coordinates it in distinct field with custom format.







No packages published