Skip to content

Commit

Permalink
feature.properties内のみ検索するように修正
Browse files Browse the repository at this point in the history
  • Loading branch information
sugama-satsuki committed Dec 13, 2024
1 parent f89c89a commit ffcd75b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class GeoJsonlookfor {
this.geojson = {
"type": "FeatureCollection",
"features": features.filter((feature: any) => {
return JSON.stringify(feature).includes(keyword);
return JSON.stringify(feature.properties).includes(keyword);
})
};

Expand All @@ -44,7 +44,7 @@ export class GeoJsonlookfor {
"type": "FeatureCollection",
"features": features.filter((feature: any) => {
if(Array.isArray(keywords)){
return (keywords as string[]).some((keyword) => JSON.stringify(feature).includes(keyword));
return (keywords as string[]).some((keyword) => JSON.stringify(feature.properties).includes(keyword));
} else {
return Object.keys(keywords).some((key) => {
return key in feature.properties && feature.properties[key].includes((keywords as any)[key])
Expand Down Expand Up @@ -73,7 +73,7 @@ export class GeoJsonlookfor {
"type": "FeatureCollection",
"features": features.filter((feature: any) => {
if(Array.isArray(keywords)){
return (keywords as string[]).every((keyword) => JSON.stringify(feature).includes(keyword));
return (keywords as string[]).every((keyword) => JSON.stringify(feature.properties).includes(keyword));
} else {
return Object.keys(keywords).every((key) => {
return key in feature.properties && feature.properties[key].includes((keywords as any)[key])
Expand Down Expand Up @@ -103,7 +103,7 @@ export class GeoJsonlookfor {
"features": features.filter((feature: any) => {
if(Array.isArray(keywords) || typeof keywords === 'string'){
const keywordArr = Array.isArray(keywords) ? keywords : [keywords];
return !keywordArr.some((keyword) => JSON.stringify(feature).includes(keyword));
return !keywordArr.some((keyword) => JSON.stringify(feature.properties).includes(keyword));
} else {
return !Object.keys(keywords).some((key) => {
return key in feature.properties && feature.properties[key].includes((keywords as any)[key])
Expand Down

0 comments on commit ffcd75b

Please sign in to comment.