title: Cloud Firestore Rules for location
body: <p>I am trying to block read in firestore for any records which aren't within 1000m radius of user's current position using <a href="https://firebase.google.com/docs/reference/rules/rules.LatLng#distance" rel="nofollow noreferrer">rules.latlng.distance</a></p>
  
  <p><a href="https://i.stack.imgur.com/Hk0sm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hk0sm.png" alt="enter image description here"></a></p>
  
  <p>I tried few cases:</p>
  
  <ol>
  <li>Rule </li>
  </ol>
  
  <pre><code>latlng.value(resource.data.location.latitude, resource.data.location.longitude).distance(get(/databases/$(database)/documents/users/$(request.auth.uid)).data.location) &lt;= 1000;
  </code></pre>
  
  <p>Error</p>
  
  <blockquote>
    <p>Property latitude is undefined on object.</p>
  </blockquote>
  
  <ol start="2">
  <li>Rule</li>
  </ol>
  
  <pre><code>latlng.value(resource.data.location.getLatitude(), resource.data.location.getLongitude()).distance(get(/databases/$(database)/documents/users/$(request.auth.uid)).data.location) &lt;= 1000;
  </code></pre>
  
  <p>Error</p>
  
  <blockquote>
    <p>Function not found error: Name: [getLatitude].</p>
  </blockquote>
  
  <ol start="3">
  <li>Rule</li>
  </ol>
  
  <pre><code>latlng.value(resource.data.location.latitude(), resource.data.location.longitude()).distance(get(/databases/$(database)/documents/users/$(request.auth.uid)).data.location) &lt;= 1000;
  </code></pre>
  
  <p>Error</p>
  
  <blockquote>
    <p>Function not found error: Name: [latitude].</p>
  </blockquote>
  
  <p>All of them result in error. The location field is of type GeoPoint.</p>