jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了jquery – 来自USGS geojson数据的jqGrid大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试阅读并在jqGrid中发布从USGS存储库中提取的一组地震GeoJSON数据.
请求被接受,但在可能满足标头元数据时显示“Uncaught SyntaxError:Unexpected token”.
$(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',jsonmap: 'properties.place'},{name: 'url',label: 'URL',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');
});

你有什么解决方案吗?
提前致谢.

解决方法

我查看了geojson的文档,我想我找到了问题的原因.似乎GeoJSON(p)使用eqFeed_callBACk作为回调名称(参见 here).所以我修复了jqGrid的一些选项,你习惯了以下几点:
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现在可以使用并显示如下结果

更新:The modified demo使用GeoJSON的新URL和free jqGrid的新版本(4.14.1).

大佬总结

以上是大佬教程为你收集整理的jquery – 来自USGS geojson数据的jqGrid全部内容,希望文章能够帮你解决jquery – 来自USGS geojson数据的jqGrid所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。