
First of all you need two fields in your database to hold the latitude/longitude. Open ext_tables.sql and add the following field definition:
gps_latitude decimal(9,6) DEFAULT ’0.000000’,
gps_longitude decimal(9,6) DEFAULT ’0.000000’,
Then we should add the corresponding fields to the edit form, let’s edit your TCA for the corresponding table:
'gps_latitude' => array( 'exclude' => 0, 'label' => 'LLL:EXT:your_ext/path/to/locallang_db.xml:tx_yourext_gps_latitude', 'config' => array( 'type' => 'input', 'size' => 10, 'max' => 10, 'eval' => 'trim', 'checkbox' => 0, 'default' => '0.00', ), ), 'gps_longitude' => array( 'exclude' => 0, 'label' => 'LLL:EXT:your_ext/path/to/locallang_db.xml:tx_yourext_gps_longitude', 'config' => array( 'type' => 'input', 'size' => 10, 'max' => 10, 'eval' => 'trim', 'checkbox' => 0, 'default' => '0.00', ), ),
Note: Needless to say that all fields you add to your TCA should be referenced in the showRecordFieldList of your TCA of course!
Now the idea is to add a virtual field which I name “map” that should be rendered with a userFunc and should show the Google Map. You probably will notice that I’m passing the field names holding the latitude/longitude as parameters. This is a
new feature for TYPO3 4.6. But wait! In versions prior to TYPO3 4.6, you will be able to render the Google Map as well, you just cannot change the hardcoded field names “gps_latitude” and “gps_longitude”.
OK, add this additional definition to your TCA:
And finally you need the code of the famous class tx_ClimbingSites_Tca_Map that you may of course further adapt and rename to fit your needs.
Download the source code (6 KB)
Ah! and do not forget that you should reference it within your ext_autoload.php file ;-)
