How to save GeoPoint in Firebase Cloud Firestore?

后端 未结 4 480
小蘑菇
小蘑菇 2020-12-24 13:01

in the database UI I can create a field with the type geopoint. After providing values, it looks something like this:

location: [1° N, 1° E]
         


        
4条回答
  •  误落风尘
    2020-12-24 13:14

    I struggled to find out the right import/require. This is what worked for me !!

    const firebaseAdmin = require('firebase-admin');
    //other code ....
    
    //assigning value to myLocation attribute
    let newObject = {
        otherAttribute:"otherAttributeValue",
        myLocation: new firebaseAdmin.firestore.GeoPoint(latitude,longitude)
    }
    

提交回复
热议问题