Is it possible to find geolocation using zip code using PHP.
For example, if i am entering the zip code i need to find the name of that particular zipcode.
Is that possible? if yes kindly explain me how?
Thanks in advance
See the duplicate question on how to turn an address into coordinates using the Google Geocoding service.
A query in the format [zipcode], United States, e.g..
72116, United States
should always work for you.
Try maps.google.com to simulate the request.
The XML returned from the Google Service will contain the official place name, as well as other information like county and state names etc.
You can do this through Javascript and PHP using Google's Map API - check this question for an example of how this is used.
I dont think it can be done solely through PHP however because you'd need to access an API's data and they normally (not always) do this through javascript.
You should check the API documentation.
You can access the Geocoding API solely using PHP.. you don't even need an API Key anymore.
http://code.google.com/apis/maps/articles/phpsqlgeocode.html
So if understand this correctly, you want to know the City/State of the zip code you have entered?
Maybe you should look into the Access database here :
http://databases.about.com/od/access/a/zipcodedatabase.htm
And if you find it useful, just convert it into a MySQL table and use as you please.
Related
We are using Yahoo YQL geo code finder to find a country code using the latitude and longitude.
Following is the url used,
http://query.yahooapis.com/v1/public/yql?q=select+*+from+geo.placefinder+where+text+%3D+%2751.5073509%2C+-0.12775829999998223%27+and+gflags%3D%27R%27+&format=json
It used to work earlier, but suddenly it has stopped providing the country code.
Following is the result given,
{"query":{"count":0,"created":"2016-02-11T06:35:28Z","lang":"en-US","results":null}}
Please help me to find a solution for this.
Regards,
Neha
Checking the yahoo console. I can't find any reference for the table geo.placefinder
Are you sure that you are using the correct API and the correct parameter.
I have run a geo location query
select * from geo.places where text= "SFO"
http://query.yahooapis.com/v1/public/yql?q=select+*+from+geo.places+where+text+=+%27SFO
Which gives me the following result
{"query":{"count":1,"created":"2016-02-11T08:09:34Z","lang":"en-US","results":{"place":{"lang":"en-US","xmlns":"http://where.yahooapis.com/v1/schema.rng","yahoo":"http://www.yahooapis.com/v1/base.rng","uri":"http://where.yahooapis.com/v1/place/12521721","woeid":"12521721","placeTypeName":{"code":"14","content":"Airport"},"name":"San
Francisco International
Airport","country":{"code":"US","type":"Country","woeid":"23424977","content":"United
States"},"admin1":{"code":"US-CA","type":"State","woeid":"2347563","content":"California"},"admin2":{"code":"","type":"County","woeid":"12587707","content":"San
Francisco"},"admin3":null,"locality1":{"type":"Town","woeid":"2487956","content":"San
Francisco"},"locality2":null,"postal":{"type":"Zip
Code","woeid":"12797178","content":"94128"},"centroid":{"latitude":"37.62207","longitude":"-122.383659"},"boundingBox":{"southWest":{"latitude":"37.603939","longitude":"-122.403732"},"northEast":{"latitude":"37.64463","longitude":"-122.35482"}},"areaRank":"1","popRank":"1","timezone":{"type":"Time
Zone","woeid":"56043663","content":"America/Los_Angeles"}}}}}
Sorry for the hard format, I can't get the tags to work the way I want it.
https://developer.yahoo.com/yql/console/#h=SELECT+*+FROM+geo.places+WHERE+text%3D%2251.5073509%22
I have found a solution which works fine in my case.
The yahoo API service is unavailable for query format, hence I have used the below format.
http://gws2.maps.yahoo.com/findlocation?q=51.5073509%2C%20-0.12775829999998223&gflags=R&format=json
Regards,
Neha
i'm using this api below to find out nearest hospitals.In response json i'm not getting the contact number of those hospitals. how do i get that????
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=22.5531,88.3564&radius=500&types=hospital&sensor=false&key=AIzaSyBdBBjxmc51SAqsefefwgwtSyjxT6NPMUAtYA
You can get only thos info which is provided by the api. Please go through this link it has a nice explanation about the apis https://developers.google.com/places/documentation/search
I think, some of these APIs are closed, so i don't see a solution with Google APIs. Maybe geonames.org or OpenStreetMap gives you a better chance for the data you are looking for.
Overpass Turbo
I'm looking for a way to get a user default language by the country. For example I have windows in english but still I would like to get my country 2 letter language ("cs")
You can see an example of what I want, In the source code of http://search.conduit.com/ using (Autocompleteplus) as well. This is what I see:
window.language = "en-us";
window.countryCode = "cz";
window.suggestBaseUrl = "http://api.autocompleteplus.com/?q=UCM_SEARCH_TERM&l=cs&c=cz&callback=acp_new";
You can see the api url has inside "l=cs&c=cz" how did they get this information? I would like to have the same thing I use the same autocompleteplus method just need a way to generate the l=(user true langague)&c=(country code) and performance is important as well. It's autosuggestions for my website search.
This is Ed from AutoComplete+. Getting the user country is typically done when using our API through server side implementations. There are however some open APIs that can assist you. Regardless, you can use our autocomplete feed without the user country. Feel free to contact us directly for further info at http://www.autocompleteplus.com
Thanks,
--ed
I have read this post and it looks very promising. However, the answer does not go in detail with regards the implementation.
Basically, given the latitude and longitude, how can I use the GeoNames Web Service to get the country. I would like the returned result to be stored in a variable so that I can then continue working with it as I wish.
Thanks in advance
Do you have to use javascript for that? Geonames doesn't seem to offer a javascript api for doing your exact query (see here: http://www.geonames.org/export/JSON-webservices.html). And remote file fetching via javascript is not a joy.
If you could use php for that, it would be as easy as
$country = file_get_contents("http://ws.geonames.org/countryCode?lat=49.03&lng=10.2");
I am doing some minor cURL work and, unlike Google, Bing defaults the search results to the location of the server. I am trying to find a parameter to set that allows me to specify location, for example UK/US, but I haven't had much luck.
Does anyone know or have a link to an article explaining this?
Thanks in advance!
I actually found it, after searching for 30 minutes and posting this I stumbled upon it. You can set it using the something like "setmkt=fr-fr"
Where the first is the language, the second the location. I can't be sure what it will accept but I figure playing with that will get the desired results.
Bing! probably does it based on the IP of the connecting client.
Since you can't change that (other than connecting via a proxy, which is a whole different story), you cannot manually set the location for your search results (unless of course, Bing! has an option or an API which allows it).
I believe you could use the Location Data parameter:
http://msdn.microsoft.com/en-us/library/ff701726.aspx
You can specify countryRegion to limit the results to a certain country:
A string specifying the country or region name of an address.
Example: United States