Google maps mini-map for customers

I wanted to move some of the google maps work I did in AX 2009. One of the bits I did originally was to produce a mini map in the customer screen:

I decided to fit better with 2012 I have moved it to a factbox. To create a fact box first you have to create a form design. In 2009 I used an Active X control (browsercpm) as it gave me more control over the browser window, however in AX2012 this is no longer present but there is an Active x control called “Microsoft Web Browser” which contained most of the same methods so I moved it to that. The form design is relatively simple, however I found out you need a datasource on a fact box as there is no method that is called between record switches unless you link a datasource. In the active of the data source I call my method. The form looks as follows:

And the custom methods are as follows:

publicvoid getGoogleMap()

{

CustTable custTableLocal;

Args args;

;

args = element.args();

if(args.record())

{

if(args.record().TableId == tableNum(custTable))

{

custTableLocal = args.record();

element.createURL(custTableLocal.postalAddress().ZipCode);

}

}

}

publicvoid createURL(Addressing _address)

{

str mapUrl;

;

mapUrl = #MiniMapURLStart;

mapUrl += GoogleMapsHelper::formatAddress(_address);

mapUrl += #MiniMapURLEnd;

MiniMapControl._Height(210);

MiniMapControl._Width(210);

MiniMapControl.Navigate(mapUrl);

}

I also have a macro to containing the start and end of the URL:

#define.MiniMapURLStart(‘http://maps.googleapis.com/maps/api/staticmap?center=Burnley, United Kingdom&zoom=4&size=200×200&markers=color:red|’)

#define.MiniMapURLEnd(‘&sensor=false’)

#define.MiniMapURLSeperator(‘&markers=color:red|’)

Along with a static method to format the address (I have used just the postcode due to issues with the data but this should format the full address correctly)