I'm currently making a android app but I ran into a bit of an issue, I'm using Parse.com as my server and I'm trying to use their ParseGeoLocation to get the current users location and compare it to the other users location using their ParseQuery.
And by this i mean (Get current user location) > (Send to server object in column "location") > (Check if within other users location) > (Return other users name/data if true)
I've been trying to do this correctly for the last few days but to no avail.
Does anyone know how to do this? I've been searching the web but not really finding the right things. I've tried on their site "Docs" but wasn't really helpful.
You can use the query whereNear constrain. You will provide your user location and call find method. This will return an array of objects ordered by distance (nearest to farthest) from your provided user location. One example code can be given as follows;
ParseGeoPoint userLocation = //current user location
ParseQuery<ParseObject> query = ParseQuery.getQuery("LocationStoredTableName");
query.whereNear("location", userLocation);
query.limit(10); //10 objects will return
query.findInBackground(new FindCallback<ParseObject>() { ... });
Hope this helps.
Regards.
Related
I am using CBL for Android. I have the latitude and longitude values that the user saved earlier. And there are also values for the location the user has marked on the map.
I need to make a query on the database using the location information the user has selected on the map. So if the records in the database are located near the location the user chose, I want to show this.
How can I do that. I have no idea how to query this in CBL. I would be very glad if you could help. Thanks in advance.
There is no out-of-box query support. From discussion thread posted here,
It’s possible to do bounding-box queries without specialized indexes;
for example (pseudocode) loc.x BETWEEN $x0 AND $X1 AND loc.y BETWEEN
$y0 AND $y1. With regular indexes on loc.x and loc.y (as opposed to
R-trees) this isn’t very efficient, but it’s workable as long as your
data set isn’t too large.
I am currently working on a program which requires containing location of users with Android Studio. In my users collection, I have location informations as geopoints for each user documents. I need to get all users which are in radius range of a circle. I found GeoFireStore of imperiumlabs -https://github.com/imperiumlabs/GeoFirestore-Android- for this geographic location processes. I can set and get location of a document(single user). But I want to define a center and check if there is/are anyone within the range.
As I understand I need to use geo query event listener as follows;
geoQuery.addGeoQueryEventListener(new GeoQueryEventListener() {...}
It has Key Entered, Key Moved, Query Ready, Query Error methods, but I couldn't manage what and how to use. I need returned informations of documents(users) which(who) are in my defined range. This way, I can show them main user.
For short words; can someone help me about understanding event listeners of geofirestore?
Thanks for your precious time.
After spending more and more hours I finally solved my issue with
public void onDocumentEntered(DocumentSnapshot documentSnapshot, GeoPoint location) {}
in the GeoQueryDataEventListener Interface. This method works recursively until meeting the requirements of query and I put it in onCreate. I just listed document_id's with documentSnapshot.getId() and tranferred them to an arraylist with mList.add(documentSnapshot.getId()) . Hope this can help someone take care.
I would like to query my data set for results that occur within a date range and location range (geohash range). I am struggling to find a good solution.
I am using GeoFire and have tried various methods of segrigating my data either by date or location. It's easy enough to build a node for each day and plop geohashes inside but how can i then page through that data without downloading all 5000 results in the city of NYC for example?
If i could sort first on the geohash and then on the date this would be easily achieved but i can not do that in firebase or any NoSQL database.
Someone must have encountered this multirange query problem and i hope you can share what you learned.
Thanks
It's easy enough to build a node for each day and plop geohashes inside but how can i then page through that data without downloading all 5000 results in the city of NYC for example?
Please let me know if I'm misinterpreting your question. Would you be able construct a DatabaseReference to the node representing a specific day, creating a GeoFire object and a GeoQuery, repeating for each day?
DatabaseReference ref = FirebaseDatabase.getInstance().getReference("path/to/dayNode");
GeoFire geoFire = new GeoFire(ref);
GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(37.7832, -122.4056), 0.6); // Use this for addGeoQueryEventListener() or something else
// See https://github.com/firebase/geofire-java
This would allow you to only download the locations in the 0.6 km surrounding 37.7832, -122.4056. To prevent downloading too many results at once, start with a small radius and increase from there?
As a side note, I believe Firebase Firestore allows for multiple cursor conditions such as:
db.collection("locations")
.orderBy("locationhash")
.orderBy("date")
.startAt(locationHash, startDate)
.limit(25);
Unfortunately, I don't think you would be able to specify a radius while sorting by date and paginating unless you extended the work done in GeoFire or GeoFirestore. Hopefully someone else has a better idea.
i currently have an android application that will find a users current location and shows places of interest within a specified radius on a map through Google places API. I am now looking for a way now to alert the user of these places when they come within the distance? e.g show a notification like "Point of interest is close by"
You can check Google's Geofencing API, I think it will be the best solution for you and also best solution battery-wise.
you just need to check for distance using lat/long of user and your fav. place .. and put a condition check that if distance is around this then do that that .. else do that .
Now just create a method that will return your coordinate data ..
For Ex:--
public String getFinalCoordinates(){
// Perform action for lat and long .. and save it like string ..
your_lat_cum_long_data = your_data;
return your_lat_cum_long_data;
}
On later terms you can convert that String to double format like ..
double lat = Double.parseDouble(string) // It's some thing like that ..
// might be here I have done some syntax error .. Please check same.
Else you are good to go ..
EDIT
you might be looking ahead to show notification when a ATM is nearby your location.
Now for this you need to put check like .. nearby ATM's, nearby restra, etc.
Now for each of defined above .. you need to put check like ..
if(places --> is equal to --> nearby ATM's)
{
//callNotificationMethod
}
else
{
// Keep pooling for places api ..
}
Try this and let me know.
I have an question that while using Google Direction Api we can get the list of data like city's name, its Lat & Lng etc but the data provided by Api is limited to some extend. It's not able to provide all cities coming with-in that particular route.
E.g. If we try to go for Chandigarh to Delhi, then the route has a fixed result but when we try to reverse that same search i.e. Delhi to Chandigarh, some of the cities coming in previous result get vanished in api's new result, moreover, we just have a limited amount of locations/cities in result while we need the route completely detailed.
Do any of you guys faced this issue before? Is there any other way to match such requirement?
Hope I am understandable.
Thanks.
Use the below url:
https://maps.googleapis.com/maps/api/directions/json?origin="latvalue","longvalue"&destination="destnLat","destnLong"
&sensor=false&avoid=highways&mode=driving&alternatives=true
you have to set the alternatives value to true so it will result different routes available between the source and destination