Tuesday, 21 October 2014

Google Maps Integration In Axapta 2012 R2 & Axapta 2012 R3


In Axapta system we can see customer / vendor address in bing.com maps.

In this customization I will show the same in google maps.




Before:

Accounts receivable/Common/Customers/All customers

Select any customer and edit

In Address tab we can see “Map”. When we click on that we can see customer address in bing maps.

After

Go to AOT-> Classes -> smmutility ->mapit (Method)

Copy and replace the below code in mapit method

/// <summary>
/// Opens Bing maps with the address.
/// </summary>
/// <param name="_address">
/// The address to map.
/// </param>
public static void mapIt(LogisticsPostalAddress _address)
{
   // #DEFINE.MapURL('http://maps.bing.com/default.aspx?where1=\%1')//Commented By Rahul
    #DEFINE.MapURL('https://www.google.com/maps/place/')//N-Code Added By Rahul Talasila
    #DEFINE.comma(',')
    #DEFINE.newLine('\n')

    str     address;
    ;
    if (_address)
    {
        address = _address.Street + #comma +
                  _address.City + #comma +
                  _address.State + #comma +
                  _address.ZipCode + #comma +
                  _address.CountryRegionId;

        // Replace the newline with comma
        address = strReplace(address, #newline, #comma);
        // URL encode
        address = System.Web.HttpUtility::UrlEncode(address);
        // Add the address to the URL
        infolog.urlLookup(strFmt(#MapURL+ address));//N-Code Changed By Rahul Talasila
    }
}


Go back to the customer->address and click on map.


 Below link helped me ..
http://querystring.org/google-maps-query-string-parameters/

@Rahul Talasila



No comments:

Post a Comment

Sorting data in a form datasource in Dynamics Ax 2012 / D365F&O X++

In Microsoft Dynamics AX, you can sort a form datasource when the form is loaded. On the form, override the init method. After the call...