gpt4 book ai didi

javascript - 使用 underscore.js 按年份过滤

转载 作者:行者123 更新时间:2023-12-03 06:17:57 25 4
gpt4 key购买 nike

我有一个传单交互式 map ,我想按年份过滤掉 geojson 数据。我想使用 underscore.js 来过滤。有问题的字段是“info_city”,其中包含年份条目。我的过滤函数如下:

function filterByYear(data){
console.log("filtering")
console.log(data)
f = _.where(data, {info_date : "2006"});
console.log(f)
return f;
}

这是我的 geojson 的设置方式:

{
"type": "Feature",
"properties": {
"info_address": "Insitut fur Rontgendiagnostik, Universitatsklinikum Wurzburg, Oberdurrbacher Str 6",
"info_city": "Wuerzburg",
"info_state": "Germany",
"info_zip": 97080,
"info_country": "",
"info_notes": "Unsure of how to format the German address",
"info_lastName": "Bley",
"info_maidenName": "",
"info_firstName": "Thorsten",
"info_middleName": "",
"info_intern": "",
"info_resident": "",
"info_fellow": "",
"info_fellowshipSection": "",
"info_honoraryFellow": "",
"info_formerFaculty": "fac",
"info_facultySection": "Thoracic Imaging",
"info_residencyBegin": "",
"info_residencyEnd": "",
"info_fellowshipBegin": "",
"info_fellowshipEnd": "",
"info_institution": "",
"info_position": "Visiting faculty",
"info_count": 1,
"info_resDate": 1900,
"info_felDate": 1900,
"info_date": 2009,
"info_status": "fac"
},

underscore.js 应该自动读取“info_date”作为字段之一吗?或者,我是否需要做一些准备并将 info_date 字段隔离为变量?

最佳答案

info_date 是一个数字,而不是一个字符串改变

f = _.where(data, {info_date : "2006"}); 

f = _.where(data, {info_date : 2006}); 

关于javascript - 使用 underscore.js 按年份过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39002310/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com