用于 arcgis 服务器查询结果的 jqgrid json 阅读器 [英] jqgrid json reader for arcgis server query results

查看:19
本文介绍了用于 arcgis 服务器查询结果的 jqgrid json 阅读器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要什么样的 json 阅读器来绘制 ).幸运的是,服务器 sampleserver1.arcgisonline.com/ArcGIS 支持 JSONP 请求.因此,要使用外部数据填充网格,您可以使用以下代码

$('#grid').jqGrid({url: 'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/4/query',数据类型:'jsonp',后数据:$.param({其中:1=1",返回几何:假,outFields: "ObjectID,NAME,STATE_NAME,CNTY_FIPS",f:json"}),col型号:[{名称:'ObjectID',标签:'ID',宽度:60,jsonmap:'attributes.ObjectID'},{name:'NAME',标签:'Name',宽度:150,jsonmap:'attributes.NAME'},{name:'STATE_NAME',标签:'State',宽度:120,jsonmap:'attributes.STATE_NAME'},{名称:'CNTY_FIPS',标签:'FIPS',宽度:60,jsonmap:'attributes.CNTY_FIPS'}],toppager:是的,jsonReader:{根:'功能',重复项:假},加载一次:真,忽略大小写:真,高度:'自动'});

这里查看新的演示.

更新 2:为了能够使用本地搜索/过滤,应该修改上面的代码.最好把上面看到的postData换成下面的参数

ajaxGridOptions: { cache: true },prmNames: {search: null, nd: null, sort: null, rows: null, order: null, page: null},发布数据: {其中:1=1",返回几何:假,outFields: "ObjectID,NAME,STATE_NAME,CNTY_FIPS",f:json"}

参见对应的demo where filterToolbar有效.

what kind of json reader I need to plot data like these in a jqgrid?

Thanks!

解决方案

You have strange questions and all about the jsonReader. In the current case you can use

jsonReader: {
    root: 'features',
    repeatitems: false
}

to read the data. The demo shows how the results can looks like:

UPDATED: How I understand, what you want really to do is to call some external URL which provide you back the JSON. Standard Ajax request can't be done to another server because of security reasons (see same origin policy). Fortunately the server sampleserver1.arcgisonline.com/ArcGIS supports JSONP requests. So to fill the grid with external data you can use the following code

$('#grid').jqGrid({
    url: 'http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/4/query',
    datatype: 'jsonp',
    postData: $.param({
        where: "1=1",
        returnGeometry: false,
        outFields: "ObjectID,NAME,STATE_NAME,CNTY_FIPS",
        f: "json"
    }),
    colModel: [
        {name: 'ObjectID', label: 'ID', width: 60, jsonmap: 'attributes.ObjectID'},
        {name: 'NAME', label: 'Name', width: 150, jsonmap: 'attributes.NAME'},
        {name: 'STATE_NAME', label: 'State', width: 120, jsonmap: 'attributes.STATE_NAME'},
        {name: 'CNTY_FIPS', label: 'FIPS', width: 60, jsonmap: 'attributes.CNTY_FIPS'}
    ],
    toppager: true,
    jsonReader: {
        root: 'features',
        repeatitems: false
    },
    loadonce: true,
    ignoreCase: true,
    height: 'auto'
});

See the new demo here.

UPDATED 2: To be able to use local searching/filtering one should modify the above code. It's better to replace postData which one sees above to the following parameters

ajaxGridOptions: { cache: true },
prmNames: {search: null, nd: null, sort: null, rows: null, order: null, page: null},
postData: {
    where: "1=1",
    returnGeometry: false,
    outFields: "ObjectID,NAME,STATE_NAME,CNTY_FIPS",
    f: "json"
}

See the corresponding demo where filterToolbar works.

这篇关于用于 arcgis 服务器查询结果的 jqgrid json 阅读器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆