Geolocation file upload field (for photos etc)

Installs: 10

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 2

Open Issues: 0



0.1.0 2016-03-10 23:40 UTC

This package is not auto-updated.

Last update: 2023-01-18 16:32:17 UTC


Build Status Latest Stable Version Latest Unstable Version Scrutinizer Code Quality Total Downloads License

File upload field for forms with a Google Map to allow the user to set the location of the uploaded media, for example photos.

Latitude, Longitude, and Zoom fields are saved in to the same DataObject as the Image the upload field is for when the form is submitted.

If the file has geolocation tags in it once the file is chosen the marker on the map will move to that location automatically (the user can adjust manually if desired).

Note this only works on front-end forms at this time.


* Silverstripe 3.1.x+
* JQuery-1.7.1+

Usage example

Add the following fields to the DataObject your form submissions are saved in to...

'Latitude'  => 'Varchar(255)',
'Longitude' => 'Varchar(255)',
'Zoom'      => 'Int',

Also ensure your data object has an Image (or other object which allows file upload)...

private static $has_one = array(
    'Image' => 'Image',

Then create your form using the GeodataUploadField instead of a normal Silverstripe upload field...

public function getFrontEndFields($params = null)
   $fields = parent::getFrontEndFields($params);

   // Create GeoData Upload field.
   $upload = GeoDataUploadField::create('Image', 'Image');

   // Set options to prevent selection of existing or access to the filesystem as per Silverstripe docs.

   $fields->replaceField('Image', $upload);

   return $fields;

Constructor options

There are a few other things you can pass to the constructor besides the field name and title. For the third parameter you can pass an array of options which will override the default options for the map in _config/geodata-uploadfield.yml.

If you have named the Latitude, Longitude, or Zoom fields differently in your DataObject you need to pass the names of them in to the constructor as the last 3 parameters otherwise nothing will be saved on form submission.

The following example shows creating a GeoDataUploadField passing some options and the differently named lat and lng fields...

$upload = GeoDataUploadField::create(
   'Image',                // Name.
   'Select an Image',      // Title
   array(                  // Options.
      'map' => array(
         'zoom' => 10
   'theLatField',          // Latitude field name.
   'theLngField',          // Longitude field name.
   'theZomField'           // Zoom field name.

Remember, as long as you have named the fields on the dataobject Latitude, Longitude, and Zoom you don't need to pass their names in to the constructor.


This module is heavily based on the BetterBrief/silverstripe-googlemapfield by Will Morgan and others which has a BSD license.

This module also includes the Javascript EXIF Reader - jQuery plugin 0.1.3 by Jacob Seidelin which has a MPL License.

All I have really done is bought these two together and modified them to work in the way I needed for a project.

I would like to thank the creators and contributors of those repositories / libraries.


zarocknz -


* Try to get this working CMS side.