来自 USGS geojson 数据的 jqGrid [英] jqGrid from USGS geojson data

查看:15
本文介绍了来自 USGS geojson 数据的 jqGrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 jqGrid 中读取并发布一组从 USGS 存储库中提取的地震 GeoJSON 数据.请求被接受,但在可能满足标头元数据时显示Uncaught SyntaxError: Unexpected token".

$(function () {'使用严格';$.extend($.jgrid.search, {multipleSearch: true, multipleGroup: true, overlay: 0});$('#grid').jqGrid({url: 'http://earthquake.usgs.gov/earthquakes/feed/geojson/2.5/week?callback=?',数据类型:'json',col型号:[{名称:'mag',标签:'MAGNITUDO',宽度:150,jsonmap:'properties.mag',排序类型:'number',格式化程序:'数字',格式化选项:{decimalPlaces:2}},{名称:'地点',标签:'LOCALITA',宽度:150,jsonmap:'properties.place'},{名称:'url',标签:'URL',宽度:150,jsonmap:'properties.url'}],toppager:是的,网格视图:是的,行列表:[10, 20, 50, 10000],行数:10,jsonReader:{根:'功能',重复项:假},加载一次:真,忽略大小写:真,高度:'自动'}).jqGrid('navGrid', '#grid_toppager', {add: false, edit: false, del: false}).jqGrid('filterToolbar', {stringResult: true, defaultSearch: 'cn', searchOnEnter: false});$("#grid_toppager option[value=10000]").text('All');});

你有什么解决办法吗?提前致谢.

解决方案

我查看了geojson的文档,我想我找到了问题的原因.似乎 GeoJSON(P) 使用 eqfeed_callback 作为回调名称(参见 使用 GeoJSON 的新 URL 和 free jqGrid 的新版本 (4.14.1).

I'm trying to read and post in a jqGrid a set of earthquakes GeoJSON data extracted from USGS repository. The request is accepted, but displays "Uncaught SyntaxError: Unexpected token" when probably meets the header metadata.

$(function () {
    'use strict';
    $.extend($.jgrid.search, {multipleSearch: true, multipleGroup: true, overlay: 0});
    $('#grid').jqGrid({
        url: 'http://earthquake.usgs.gov/earthquakes/feed/geojson/2.5/week?callback=?',
        datatype: 'json',
        colModel: [
            {name: 'mag', label: 'MAGNITUDO', width: 150, jsonmap: 'properties.mag', sorttype: 'number',
formatter: 'number', formatoptions: {decimalPlaces: 2}},
            {name: 'place', label: 'LOCALITA', width: 150, jsonmap: 'properties.place'},
            {name: 'url', label: 'URL', width: 150, jsonmap: 'properties.url'}
        ],
        toppager: true,
        gridview: true,
        rowList: [10, 20, 50, 10000],
        rowNum: 10,
        jsonReader: {
            root: 'features',
            repeatitems: false
        },
        loadonce: true,
        ignoreCase: true,
        height: 'auto'
    }).jqGrid('navGrid', '#grid_toppager', {add: false, edit: false, del: false})
      .jqGrid('filterToolbar', {stringResult: true, defaultSearch: 'cn', searchOnEnter: false});
    $("#grid_toppager option[value=10000]").text('All');
});

Do you have any solution? Thanks in advance.

解决方案

I looked in the documentation of geojson and I think I found the reason of the problem. It seems that GeoJSON(P) uses eqfeed_callback as callback name (see here). So I fixed some options of jqGrid which you used to the following:

url: 'http://earthquake.usgs.gov/earthquakes/feed/geojsonp/2.5/week',
datatype: 'jsonp',
postData: '',
ajaxGridOptions: { jsonp: false, jsonpCallback: 'eqfeed_callback', cache: true},

The modified demo works now and display the results like below

UPDATE: The modified demo uses new URLs of GeoJSON and new version (4.14.1) of free jqGrid.

这篇关于来自 USGS geojson 数据的 jqGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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