リファレンス · 場所:大陸の国と検索(サイズはすべての段階を含みます)
searchPlaces関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
What a person typed, found among countries and cities, best first. Names are compared folded (case, accents, width and
kana set aside, as fold does) over the English, Japanese and native names, and over a country's reading in kana; a city's
Japanese name is found as it is written (パリ, 東京), since no source gives a city's reading. A match is ranked: the whole name, then the
start of the name, then the start of a word in it, then anywhere in it; among equal matches the more populous place
comes first. Only the tiers asked for are loaded (by default the capitals and the cities of 100,000 or more); with
country, that country's cities, every tier, and no countries.
インポート
import { searchPlaces } from "@johnmorrisdotca/kuni/places";
定義
function searchPlaces(text: string, options?: SearchPlacesOptions): Promise<PlaceHit[]>
引数
| 名前 | 型 | 説明 |
|---|---|---|
text | string | What somebody typed; empty or all punctuation finds nothing. |
options (省略可) | SearchPlacesOptions | The language of the labels, how many, and which cities to look in. |
戻り値
Promise<PlaceHit[]>
The hits, countries and cities mixed, best first.
例
import { searchPlaces } from "@johnmorrisdotca/kuni/places";
const found = await searchPlaces("paris");
console.log(found[0].kind); // "city"
console.log(found.some((one) => one.kind === "city" && one.city.country === "FR")); // true
console.log((await searchPlaces("にほん", { lang: "ja" }))[0].label); // "日本"
console.log((await searchPlaces(" ")).length); // 0city
true
日本
0出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。