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

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

Related

How to search for Nearby Places with both Radius and rank=distance in 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

Get random address/coordinates in a specified town

Is there any way to give Google Maps API or a similar API a town name and have it return a random address inside the town? I was hoping to be able to get the data as a JSON so I could parse it with SwiftyJSON in XCode and use it, but I can't seem to find any way to get the address in the first place. If coordinates would be easier to get, then those would work too, as long as its random and inside the town borders.
You can try to use Google Places API Web Service. It allows you to query for place information on a variety of categories, such as: establishments, prominent points of interest, geographic locations, and more. You can search for places either by proximity or a text string. A Place Search returns a list of places along with summary information about each place.
A Nearby Search lets you search for places within a specified area. You can refine your search request by supplying keywords or specifying the type of place you are searching for.
A Nearby Search request is an HTTP URL of the following form:
https://maps.googleapis.com/maps/api/place/nearbysearch/output?parameters
where output may be either xml or JSON values.
And if you want either address or coordinates, you can use Geocoding for it. Here i found a tutorial on how to use Geocoding in IOS.

Fetch the data from sqlite database with multiple columns and rows

I am creating an app for iPhone in which I am using sqlite to create a database. I wrote a query in which it returns 4 columns with multiple rows.
First column have values like indian territory(NORTH,SOUTH,EAST,WEST), in Second column it have the states name which belongs to these territory. There is almost 4 states in each territory. It may increase after some time. Third and fourth column have some no data which is belong to that state. How to show If I clicked in south territory then it should show all the south states in tableview. How to match the state names with its territory and fetch data according to that.
Now I have to add all states according to territory, please not give me static code like Territory= INDIA EAST, because if territory increases than it will fail.
I have to add all states into different arrays according to its region like all south in one array and all north in one array and so on..
We could use a look at your schema, but a query like this sounds like it would work:
select states from my_table where territory = 'NORTH'
You can run sqlite3 from Terminal and execute queries there, which will help you concoct your queries. Also I suggest looking at FMDB, which offers a nice API to help interface your code to SQLite. It has excellent documentation which will help translate your query's results into ObjC/Swift data structures.

How to only get places having phone numbers via Foursquare api?

i am trying to implement forsquare api in my project to get nearby places, but i want the places with phone numbers only.
The following url is created when searching for some places:
https://api.foursquare.com/v2/venues/search?client_id=NUAAA4QFSP...MEW5QYULV&client_secret=FIGD...X0LQBAB&v=20131109&locale=en&categoryId=4d4b7105d754a06374d81259,4d4b7105d754a06376d81259&ll=33.85982057734948,35.55264679015678&radius=2000
The problem is the result will contains all the places corresponding to the categories I checked and within the radius 2000.
I tried to add "query", but this will only search in the result name
So how to get only the places with phone numbers?
Thank you

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