1.0.3 • Published 3 years ago

simpletileclient v1.0.3

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

めっちゃシンプルなタイルクライアント

国土地理院などが配布しているタイル形式の配布物を比較的簡単に取得するためのライブラリです。
内部に Axios を搭載してます。

使用例

import { SimpleClient } from "simpletileclient";

const client = new SimpleClient(
  "https://cyberjapandata.gsi.go.jp/xyz/experimental_rdcl/{z}/{x}/{y}.geojson"
);

client
  .get(16, 57442, 26004)
  .then((tile) => console.log(tile))
  .catch((e) => console.error(e));

API

Constructor


new SimpleClient(url: string, reqOpt?: AxiosRequestConfig) —タイルを取得するクライアントを作成する。
urlには{z},{x},{y}の三つがそれぞれ含まれている必要がある。
画像や Pbf 形式のものなどはreqOpt.responseTypereqOpt.headersなどを設定しないとデータを正しく取得できない。
また、urlを設定せずにreqOpt.baseURLで設定すると正しく取得できない。

Method


get(zoom: number, x: number, y: number)=>Promise
インスタンスを作成したときに指定した URL の {z},{x},{y}をそれぞれ置き換えて axios の get メソッドを使用し、
レスポンスを返す。

getByRect(zoom: number, cx: number, cy: number, width: number, height: number)=>Promise<AxiosResponse[]>
cx,cyを中心として幅width,高さheightの範囲のタイルを全取得し、それぞれを配列にして返します

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago