Autofill Client Address + Client Map with Google Map API (includes trace route)

Hi there,

As I work on my site with Invoice Plane to allow me to display a Map with PINS to mark my client locations (I usually send a product to them and I want that for stats and promos) I came accross the idea of using Google Map API v3 to retrieve latitude,longitude for each client address and save that to the database.

Obviously is the prior step as I needed lat,lng to pin the markers on a larger map.

Anyways I leave here the files for those interested in having the same function on your Invoice Plane.

Remember that this modification ONLY WILL WORK with GOOGLE MAP API KEY.


1- Create a Custom Field “Full Address” on Client Table.
2- Keep the ID as you will need to replace for the ID 4 on my files.
3- Create a Custom Field “Latitude” on Client Table.
4- Keep the ID as you will need to replace for the ID 8 on my files.
5- Create a Custom Field “Longitude” on Client Table.
6- Keep the ID as you will need to replace for the ID 9 on my files.

1- Download both files
2- Copy traceRoute.js to your site > /assets/core/js/traceRoute.js
3- REPLACE lat: -33.273690, lng: 151.484360 to match your Warehouse/Location.
4- Backup your file application > modules > clients > view > form
5- Copy “form.php” to the location above
6- Upload files to your server

DISPLAY LAT,LNG ON partial_client_table.php
1- Open Application > modules > clients > views > partial_client_table.php
2- AFTER <?php _trans('client_name'); ?> ADD <?php echo 'Lat/Lng'; ?>
3- AFTER foreach ($records as $client) :

		$CI = &get_instance();
		$custom_fields = array('client' => $CI->mdl_custom_fields->get_values_for_fields('mdl_client_custom', $client->client_id),);

4- AFTER <?php echo anchor('clients/view/' . $client->client_id, htmlsc(format_client($client))); ?>

<td><?php if((!empty($custom_fields['client']['Latitude'])) && (!empty($custom_fields['client']['Longitude']))){ ?>
			   <?php echo nl2br($custom_fields['client']['Latitude']); ?>,<?php echo nl2br($custom_fields['client']['Longitude']); ?>
               <?php }  ?></td>

2 files needed, instructions and screenshots on MEGA: 286 KB file on MEGA