I am trying to accomplish a two step task on the server side using Google Map API v3 rather than on the client side but have not found much documentation as to how to accomplish this. So I was wondering if anyone here can help or guide me in the right direction.
The 1st step is getting the geo-code location of an address using PHP. I think I have figured this out and that is by making a curl call to http://maps.google.com/maps/api/geocode/json?sensor=false&address= and processing the JSON response. Once I have the geo-codes, I store them in my database.
The 2nd step is finding random addresses in a specific radius of the address in 1st step. This I cannot seem to find how to do in the server side.
Any help or guidance would be truly appreciated.
Easiest way
$url = 'http://maps.google.com/maps/api/geocode/json?sensor=false&address=' . urlencode($address);
$data = json_decode(file_get_contents($url), true); // insert in the database
Searching with the given radius and center point (lat, lng): https://developers.google.com/maps/articles/phpsqlsearch
Related
First of all I would like to tell you that I am not sure if I use the terms correctly so please excuse me for any misunderstandings. I will try to clear everything.
What I want to do is to let the users on my website to select their favorite bar or restaurant and add it to their profile.
It should be more or less like maps.google.com but in a smaller dimensions let's say 400x400. The users will be able to search for a place and once they find it they will be able to save it to their profile.
I am confused though because Google offers the Google Maps and the Google Places. I do not see any tutorials around regarding Google Places..
The question is.. Can I do my small project by using google maps or I really need to use google places?
Is there any tutorial/link which shows how to store on my database the current map location?
Thanks in advance!
Ok after some more searching I found my answer which was pretty simple.
It looks like I can get the lat and lng from place.geometry.location .
The rest about storing it to the database is easy!
Thanks anyone who at least read my post!
Cheers!
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 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");
How can I code something which'll calculate the driving distance between 2 zip codes within the USA in PHP. An API or web service that has SOAP or REST will also do.
But I understand GoogleMaps API can't be used because it violates the TOS.. So I need a way without using Google Maps, because I have no intention of using their maps, just calculate the distance.
There isn't a whole lot out there that's free, other than Google Maps. The MapQuest API may give you what you need. Here's their guide to the service - it addresses getting driving distances/times between a set of points. Their terms of service don't appear to require that you display a map, but take a look and see if that meets your needs.
Google Maps Distance API has this exact Functionality. You can get a return as either xml or json.
Here is the documentation
https://developers.google.com/maps/documentation/distancematrix/
Here is a sample of the request url :
http://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Victoria+BC&mode=bicycling&language=fr-FR&sensor=false
One nice thing is you dont have to calculate the long/lat first
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.