How to search for Nearby Places with both Radius and rank=distance in iOS - ios

As per Google Places API, I cannot search for nearby places using both Radius and rank=distance filters in place. Has anyone come up with alternate ways to tackle this issue?
var urlString = "https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=\(coordinate.latitude),\(coordinate.longitude)&radius=\(radius)&rankby=distance&sensor=true&key=\(googleAPIKey)"

This is not possible. Instead, I used radius= to get all the nearby places and then sorted in ascending order by distance from user location using array.sorted(:by method

Related

How could I query Firebase geo locations without GeoFire in order to return results based on distance between two points?

Firebase just updated their sdk to 3.x and the current version of GeoFire 2.x doesn't work.
What I would like to know is the best way to store geo location values so that I can query firebase so that we only return location with in a defined radius around the user.
Example: user defines that they would like all items that are within 20 miles or less from them.
I wonder if I could store a single value from the latitude and longitude that would allow me to quickly query for this data? Or maybe that isn't the right approach ?
It is not possible using pure firebase without implementing some sort of geohash (it is what geofire does). You could use an externa index stored in elastic search or in redis for example

Is it possible to limits google places to one or two places like restaurants or coffeeshops?

I'm building an app in swift that can filter places to one or two types of locations e.g restaurants or coffeeshops is that possible and how its done ?
The app fetch data only from these places.
YES you can search via Types in the google places like in this example
https://maps.googleapis.com/maps/api/place/textsearch/json?query=Mexican+Restaurant&sensor=true&location=40.846,-73.938&radius=20&key=yourKeyHere
Explanation:
This will give you result in the radius of 20km with all types of restaurants in Mexico. you can also check this documentation for a lot of different variation.
https://developers.google.com/places/?csw=1#PlaceSearchResults

Instagram API returning results out of the given radius

I'm using the Instagram API and giving a longitude, latitude and radius.
Except relevant results from that location, I seem to be getting few (like 1) results from outside that radius, sometimes in a different continent.
Is it possible Instagram is returning results that they consider relevant to that geo area or something? Is that a known issue?
Example query:
42.698, 23.322
5km
And i'm using the /media/search endpoint
I tried using Apigee.com to stimulate that query but they seem to be returning partial results:
https://apigee.com/snapshot/instagram?snapId=apigee-console-snapshots-1422766800000_058d16ec-932d-4c21-ad26-354fba9abf63
(I get like 900+) results, not 14-15
Thanks..
I couldn't reproduce that behavior by using those coordinates. Can you be more specific about how you consistently get that situation?

Given longitude and latitude, how to find country

If I have a latitude and longitude, how do I find out the country of that location..
If found out about Google Reverse Geocoding, but unfortunately, it requires the service to be used along with Google Maps, which is not my case..
Is there a static database or something which I can refer to? It would be better if I have a static database as opposed to a service..
Without a service, it is a lot of work.
First, you need the country polygons with assigned country codes. One country will have on average approx 50.000 vertices.
Then it's a simple point-in-polygon search.
Use a spatial index to limit the country polygon to search.
It becomes a bit more difficult if you have to consider enclaves.
You can use Bing Maps Api, it doesn't require displaying maps as far as I know,
http://dev.virtualearth.net/services/v1/geocodeservice/geocodeservice.asmx/ReverseGeocode?latitude=22.98&longitude=35.43637&key=[YOU_KEY]&culture=%22en-us%22&format=json
You can use the geonames.org "Country code / reverse geocoding" webservice, for example:
http://api.geonames.org/countryCode?lat=47.03&lng=10.2&username=demo
-> AT

Twitter Stream api filter by location AND track

I'm using the following line in order to get geolocated tweets that contain a certain keyword. (I'm using the word Madonna)
https://stream.twitter.com/1.1/statuses/filter.json?track=Madonna&locations=-180,-90,180,90
My problem is that result is not consisted by geolocated tweets that contain the keyword Madonna, but is consisted by geolocated tweets in general.
Any help on what I'm doing wrong here?
"-180,-90,180,90" - it is worldwide location;
Currently for use "AND" instead of "OR" in Twitter stream API you need make request like this: https://stream.twitter.com/1.1/statuses/filter.json?locations=-74,40,-73,41 and filtered results by "Madonna" inside your app after. Unfortunatly, I can not find another way for today;
Filtering by locations can contain:
If coordinates is empty but place is populated, the region defined in
place is checked for intersection against the locations bounding box.
Any overlap will match.
Another, somewhat hack-y solution to this, is you can have a track key work that would never match, such as "dkghaskldfnascjkawenaf", and add a location bounding box.
The API does an OR relationship between tracking and location, you'll only receive tweets from within (or very nearby) the bounding box

Resources