外部APIの整形

(function($){
    $(function(){
        $('#btn a').click(function(){
            // Insert text to #r
            $('#result').empty().append('Finding matches..');

            var endpoint = 'http://api.gnavi.co.jp';
            var apiName = 'RestSearchAPI';
            var version = '20150630';

            // Set searching word
            var inputText = $(this).text();

            var conf = {
                keyid: '134283158778e27ec9e22b6a48c8b270',
                format: 'json',
                latitude: position.coords.latitude,
                longitude: position.coords.longitude,
                freeword: inputText,
            };

                // Make requiest URL
                var request = endpoint + '/' + apiName + '/' + version + '/?';
                var loopCount = 1;
                for (var key in conf) {
                   var delimiter = '&';
                   var uri = key + '=' + conf[key] + delimiter;
                   request += uri;
                };
                console.log(request); // http://api.gnavi.co.jp/RestSearchAPI/20150630/?keyid=134283158778e27ec9e22b6a48c8b270&format=json&latitude=35.8383088&longitude=139.38446489999998&freeword=%E4%B8%AD%E8%8F%AF