Accessing locations in Objective-C - objective-c

For my app I will need to access different town and store data for each town. Basically it will be a 2d array with one dimension being the town and the next the data. I was just wondering (using Xcode and Objective C) how I could access every town in a country (I'm looking at the UK if that helps). I don't need it on a map I just need it so people can store data relative to their town simply by searching for the town and adding their data to the array for that town. Thanks in advance!

There are a couple of ways to do it. If you want to use the user's device GPS to identify its location, than you can use the Google Places API that you can install through cocoapod
If you want to perform a search, you can obtain a API key from Google and then use their URL based search. For example, this URL should return a list of Starbuks in Seattle. There are more parameters that can be set and can apply to your case.
https://maps.googleapis.com/maps/api/place/textsearch/json?query=starbucks+seattle&sensor=false&key=YOUR_API_KEY

Related

In magento 2, zip code text box to search the store available or not

I am new to Magento.
I want a text box where i can type the zip code and if the store available in that location then i need to show the products of that particular store otherwise we need to show that "the store is not available in particular location".
The following is the example site. i want it as it is.
this site prompts for users zip location .after it will display stores of that particular.
Click on this link to see the working example
how do i do this . Do i need to install a module ?
Follow Some Steps:
You need an entity 'store' that is bound to a geo location.
You need to create a multi select attribute which values are located (using a
source model) with these stores. This way, you can attach a single product to
multiple stores (one to many relation)
Then you need some sort of external API to convert a postcode entered by the
customer to a geo location. I assume the Google Maps API can do this. It would
be best to handle this server side.
Then you need the math to calculate the distance between 2 geo locations in
your database query (probably enough to find on that subject on Google) and
filter your product collection on that.
Once you have the collection you have the power.
The external API will probably have a request threshold so you might have to
pay for that (depending on the traffic).
You need to determine the radius of maximum distance between 2 geo locations.
In a small country like the Netherlands stores could be a couple of km's apart
from each other, whilst in the United States it's not uncommon to have stores
tens or hundreds of km's from each other.
**Best Of Luck For Your Project**

What is the best way for an user to enter their 'city' in a web app?

Apologies if the question is a bit vague.
This is what I want to achieve in my web application, which can have users from anywhere.
I want to be able to find the proximity of two users, from their cities. The application is not asking for an address or any exact location. I'm trying to find the proximity of users through their residing cities.
The application let the users choose their country and state via drop down lists. However, I'm not sure what is the efficient way to achieve this with cities.
I need the application to be:
Let the users enter cities by choosing from a list. That way, there wont be misspellings, etc.
Need to be able to determine the proximity of two users by the cities. So I need a way to somehow get the longitude and latitude of the city.
So my questions are:
Is there a standard list of cities for each country/state? How does web applications suggest cities while we are typing?
Is Google distance matrix the best way to implement this? https://developers.google.com/maps/documentation/distance-matrix/intro
Thank you.
There are lots of online plugins for lists of cities.
Look into: http://www.jqueryscript.net/form/City-Autocomplete-Plugin-with-jQuery-Google-Places-API.html
Also, for the distance approx., you should take a look into MongoDB.
https://docs.mongodb.com/manual/tutorial/calculate-distances-using-spherical-geometry-with-2d-geospatial-indexes/

Geocoding with rails search

I've been running into some location based searches using the Google Maps API (more of a structural issue on my end than any criticism of the mapping api)
For example, if a user searches for "Victoria, Canada" it will bring up results for "Victoria, Canada" as expected. However, if a user searches for "Canada," google returns a longitude and latitude for the middle of the country, which is essential for correctly centering the map. However, it will not display any results since the nearest location is too far away from the location returned by google. I'm filtering out results that are about 20 miles away.
Can the Google Maps API return anything that I could use to tell if a user has entered a state or country name? If not, has anyone developed a work around solution?
Ideally, I would like to avoid just ordering the results by nearest location. I don't want items for "Spain" showing up at the bottom of a list when a user searches for "United States." I would try to determine if the query is a state or country prior to the search, but this seems very daunting task given the different possible spelling of country and region names. If I was only expecting english spellings, it would be a much easier approach.
Assuming this is a form on a site that has a controller parse the form and send the request to Google's API, you could break the form out into address, city, state, and country (if needed) form elements then make the address and city required fields.
I'm doing a similar approach with a site I'm building using Google Places API and it seems to work for me.

limit address search by distance

I recently joined a team working on an application that maintains listings with addresses. The user searches, and includes their zipcode, and the application displays the distance to each listing. Currently we use the Google Maps API for this. Reading through questions here on StackOverflow seem to suggest that this is the best way of doing things:
php/mysql zip code proximity search
Search engine by distance
However, while reading through the API documentation, this seems to be expressly forbidden unless we also show a map for each result (and possibly also for each result we filter out, depending on how you read the following statement):
Use of the Distance Matrix API must relate to the display of information on a Google Map; for example, to determine origin-destination pairs that fall within a specific driving time from one another, before requesting and displaying those destinations on a map. Use of the service in an application that doesn't display a Google map is prohibited.
( https://developers.google.com/maps/documentation/distancematrix/ )
What's the best way to accomplish this without running afoul of any API terms?
do you consider the Geo::PostalCode module (perl)? It uses maxmind database to calculate distances between locations (and there is bind in different languages).

How can I use Google Maps API to search both places and postcodes?

I've been using the Google Maps Places API to do search a map for the iPhone, like in the Maps app itself. I use a line like this:
https://maps.googleapis.com/maps/api/place/search/json?location=%f,%f&rankby=distance&name=%#&sensor=true&key=%#
using NSString to enter the missing information. However, unlike the Maps app, this search only works for local places and not for postcodes or other information. It would appear that if I want it to accept postcodes, I have to create a geocode request:
https://maps.googleapis.com/maps/api/geocode/json?address=W1A+1AA&sensor=true
But then of course, this doesn't search place information. Like the Maps app, I want my app to seamlessly return the best results of both.
Before I go ahead and code it so that it uses two separate APIs, is there a better way of doing this? Should I be using a different API that works more like the search in the Maps app?
I've looked into this for something like looking into a specific service, let's say sushi, at a zip code for those who don't want to use location services. Unfortunately, it seems like you have to make two calls, one for geocoding and the other through Google Places to get the locations that are within the radius of the coordinates given in the geocoding call.
See:
Find all parks for a given zipcode with google maps
and
https://groups.google.com/forum/?fromgroups#!msg/google-places-api/P3iDK5kO7OM/Cek4BzeXMA4J