Skip to content

Firestore GeoPoint query ignores longitude #826

@lmgc-code

Description

@lmgc-code
  • Firebase SDK version: 5.0.1
  • Firebase Product: firestore

Firestore query on GeoPoint fields, compares the latitude but ignores longitude. Result contains all the documents with correct latitude, but all available longitude, ignoring the query input.

In the case of getting all the documents within map's bounding box, it returns with all the points vertically within the view, but horizontally, across the entire globe.

Following example should return only one location (40, -80), but it returns two including (50,-90) .

Relevant Code:

    const path='locations';

    const southWest=new firebase.firestore.GeoPoint( 35, -85);
    const northEast=new firebase.firestore.GeoPoint( 60, -75);

    Promise.all( [
      firebase.firestore().collection(path).doc().set( {location: new firebase.firestore.GeoPoint( 30, -70 )}),
      firebase.firestore().collection(path).doc().set( {location: new firebase.firestore.GeoPoint( 40, -80 )}),
      firebase.firestore().collection(path).doc().set( {location: new firebase.firestore.GeoPoint( 50, -90 )})
    ])
    .then(()=>{
      return firebase.firestore().collection(path)
       .where(`location`, '>' , southWest )
       .where(`location`, '<' , northEast )
       .get()
    })
   .then(snapshot=>{
     snapshot.docs.forEach(doc=>{
       console.log(JSON.stringify(doc.data()))
     })
   })

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions