Tuesday, 23 September 2014

Show path between two Address on google map in Odoo ( formerly openerp )

To show path, distance and duration between source and destination address on google map , just use this simple function in Odoo. An new window will pop up in browser, showing path between source address and destination address .

def show_path_on_google_map(self, cr, uid, ids, context=None):
    ''’ Function to show path between Source and Destination Address on Google map '''
    url="http://maps.google.com/maps?saddr="
    # Demo Addresses
    source_address = ' Mumbai, Maharashtra '
    destination_address = 'Red Fort Delhi, India ,110006'
       
    url += source_address + '&daddr=' + destination_address
    return {
        'type': 'ir.actions.act_url',
        'url':url,
        'nodestroy': True,
        'target': 'new'
    }




Thanks

Sonu Chaudhary