コード例 #1
0
        private string GetIpLocationByIp(string ip, string appKey)
        {
            var aMapIp = new AMapIpResult();

            AsyncHelper.RunSync(async() => aMapIp = await AMapServiceProxy.GetIpLocationByIp(ip, appKey));
            if (aMapIp != null)
            {
                if (aMapIp.Status == 1)
                {
                    return($"{aMapIp.Province}{aMapIp.City}");
                }
                else
                {
                    Logger.Warn($"GetIpLocationByIp Error:{aMapIp.Info}");
                }
            }
            return(null);
        }
コード例 #2
0
        private string GetGpsLocationByGps(string gps, string appKey)
        {
            var aMapGps = new AMapGpsResult();

            AsyncHelper.RunSync(async() => aMapGps = await AMapServiceProxy.GetGpsLocationByGps(gps, appKey));
            if (aMapGps != null)
            {
                if (aMapGps.Status == 1)
                {
                    return(aMapGps.RegeoCode?.Formatted_Address);
                }
                else
                {
                    Logger.Warn($"GetGpsLocationByGps Error:{aMapGps.Info}");
                }
            }
            return(null);
        }