首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在android应用中使用geonames web servics

如何在android应用中使用geonames web servics
EN

Stack Overflow用户
提问于 2014-06-02 09:54:22
回答 2查看 869关注 0票数 0

为了学习,我想在我的android应用程序中使用geonames web服务。所以我跟着这个样本

但结果是我得到了这样的方法:

{“status”:{“message”:“请在每个调用中添加一个用户名,以便geonames能够识别调用的应用程序并计算信贷使用情况。”,"value":10}}

然后我发现我必须在GeoNames网站注册,.so,我注册了,但什么都没发生。最后一步:如何在代码中显示此注册??

EN

回答 2

Stack Overflow用户

发布于 2014-06-04 17:54:52

当您转到激活链接时,页面中有一个“启用”链接,位于bug图标和菜单上方。单击它可以启用acount。

票数 1
EN

Stack Overflow用户

发布于 2015-12-26 07:53:33

你必须传递用户名..。

代码语言:javascript
复制
$(document).ready(function() {
    $( "#city" ).autocomplete({
        source: function( request, response ) {
            $.ajax({
                url: "http://ws.geonames.org/searchJSON",
                dataType: "jsonp",
                data: {
                    style: "medium",
                    maxRows: 10,
                    featureClass: "P",
                    continentCode: ["NA","SA","EU"],
                    q: request.term,
                    username: "demo"
                },
                success: function( data ) {
                    if( typeof(data.status) != 'undefined' ){ //An error occured
                        var errorObject = data;
                        //Now we have access to errorObject.status, errorObject.status.message and so on
                        //Let's do something with the error object
                        return; //Stop parsing function
                    } 
                    response( $.map( data.geonames, function( item ) {
                        return {
                            label: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryCode,
                            value: item.name + (item.adminName1 ? ", " + item.adminName1 : "") + ", " + item.countryCode,
                            lat: item.lat,
                            lng: item.lng
                        }
                    }));
                },
            });
        },
        //Start Search after user types...
        minLength: 2,
        select: function( event, ui ) {
            // Set Location for map
            $( '#lat' ).val( ui.item.lat );
            $( '#lng' ).val( ui.item.lng );
        },
        close: function() {
            //UI plugin not removing loading gif, lets force it
            $( '#city' ).removeClass( "ui-autocomplete-loading" );
        },
    });
  });
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23991779

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档