5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Firestoreに緯度経度を保存する

Last updated at Posted at 2019-12-30

記事にするほどでもないけど。
GeoPoint型を利用する。newしてやらないといけないみたい。

db.collection("geos").add({
      geopoint: new firebase.firestore.GeoPoint(Number(values.latitude), Number(values.longitude)),
});

あと、latitudeは-90~90で、longitudeは-180~180の間。

取得は、下記のような感じで。

const snapshots = await db.collection("geos").get();
const docs = snapshots.docs.map(doc => doc.data());
docs.map(doc => {
     console.log(doc.geopoint.latitude);
     console.log(doc.geopoint.longitude);
})
5
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?