Using X++ code achieve access to Google Maps

Somtimes,Purchase or sale market User hope to know the customer or vendor address.

so,I have used X++ code achieve to access to Google Maps.

Come on!Enjoying...
worte by Jimmy on Feb 16th 2011.

 

static void Jimmy_GoogleMaps(Args _args)
{
/**
Google maps begin here
worte by Jimmy on Feb 16th 2011
*/
    #Define.MapURL('Http://maps.google.com.au?q=\%1')
    #Define.comma(' ')
    #Define.newLine('\n')
    str     addressStr;
    Address Address;
;
    select firstonly Address where Address.Street != '';

    addressStr = Address.Street + #comma + Address.City + #comma +  Address.State + #comma +
                 Address.ZipCode + #comma + Address.CountryRegionId;
    if(!Address)
        addressStr = "南丰县 太和镇 太和村 黄家岭" + #comma + "抚州市" + #comma + "江西省" + #comma +  '中国';
        //addressStr = "石城县木兰乡东坑村沉香排" + #comma + "赣州市" + #comma + "江西省" + #comma +  '中国';        ;
        //addressStr = "石城县 木兰乡 新河村" + #comma + "赣州市" + #comma + "江西省" + #comma +  '中国';
        //addressStr = "东城区余屋工业区草塘一路18号" + #comma + '东莞市' + #comma + '广东省' + #comma +  '中国'
       

    //Repalce the newLine with comma
    addressStr = strReplace(addressStr,#newLine,#comma);

    //URL Encode(使用指定的编码对象对 URL 字符串进行编码,以便实现从 Web 服务器到客户端的可靠 HTTP 传输。)
    addressStr = System.Web.HttpUtility::UrlEncode(addressStr);

    //Add the address to the URL
    Infolog.urlLookup(strfmt(#MapURL,addressStr));
}
posted @ 2011-02-16 09:05  Fandy Xie  Views(325)  Comments(0Edit  收藏  举报