PHP code example of zarocknz / silverstripe-geodata-uploadfield

1. Go to this page and download the library: Download zarocknz/silverstripe-geodata-uploadfield library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zarocknz / silverstripe-geodata-uploadfield example snippets


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

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

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.
   $upload->setCanAttachExisting(false);
   $upload->setCanPreviewFolder(false);

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

   return $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.
);