Listing all users currently located in a give place
  • Hi,

    I am struggling trying to find which API I should use to retrieve a list of all the users that are currently within a give place.

    What I plan to do is:
    1. create a set of places
    2. users can subscribe a subset of places, so that they will notified (with geofencing) when they reach any of the subscribed place
    3. when they reach the place, a list of other users currently there should be created and showed to the current user
    4. (optionally) if any other user reach the place, the previous list should be automatically updated showing the new users. If a user leave the place, the list should be updated accordingly. 

    I think to use Places/Triggers API for 1, Layer/Subscribe API for 2 (is there a way to subscribe just to a place?).
    Once at 3, a trigger should call a callback to my server code, but which API I should use to retrive all the other users within the reached place?

    Maybe the solution is behind my eyes, so I am sorry if this feels like a silly question

    Any hints would be really appreciated

    thanks a lot in advance


  • 1 Comment sorted by
  • We don't have an API method to do this for a specific place, but there is one that can tell you which users are at any place on a layer.

    Check out the documentation for layer/users/:id. The response contains two objects, "users" and "places".

    The "users" object contains a list of all users currently at some location on the layer. Each user contains an array with place IDs of any places they are currently inside.

    The "places" object contains a list of all the places on the layer. Each place contains an array with user IDs of any users that are currently there.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion