티스토리 수익 글 보기
Use geospatial queries
You can perform geospatial queries in Firestore to build location aware services. For example, you can find the distance between a user and nearby points of interest, sorting them from nearest to farthest.
Edition requirements
The geospatial query feature requires a Firestore Enterprise edition database.
Before you begin
To perform a geospatial query, you must first create geospatial indexes for the fields you need to search through.
Run a geospatial query
To perform a geospatial query, use the geoDistance expression within the
query parameter of the search(...) stage.
Only the less than or equals (<=) operator is supported. The distance is
measured in meters.
For example, the following query finds all restaurants within 1,000 meters of the listed geopoint.
Web version 9
firestore.pipeline().collection('restaurants') .search({ query: field('location') .geoDistance(new GeoPoint(38.989177, -107.065076)) .lessThan(1000 /* m */) });
iOS
firestore.pipeline().collection("restaurants") .search( query: Field("location") .geoDistance(GeoPoint(latitude: 38.989177, longitude: -107.065076)) .lessThan(1000) )
Android
firestore.pipeline() .collection("restaurants") .search(new SearchOptions() .withQuery(field("location") .geoDistance(new GeoPoint(38.989177, -107.065076)) .lessThan(1000 /* meters */)));
Node.js
firestore.pipeline().collection('restaurants') .search({ query: field('location') .geoDistance(new GeoPoint(38.989177, -107.065076)) .lessThan(1000 /* m */) });
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-10-19 UTC.