1. Before using Google API, we need to apply for a key, which is appended to the URL as a unique indicator.
2. Google Maps API has an address where you can find detailed information about a location, for example, in Beijing: http://maps.google.com/maps/geo?q=beijing
3. We can also add a parameter to the above address, let it output the data we want, for example, we need CSV data, then the address becomes http://maps.google.com/maps/geo?q=beijing&output=csv
4. So we get 4 data, the first is the HTTP return address, the second is the accuracy, the next 2 is the coordinates, know that the left can not be positioned to a certain point, then how do we get the data behind it? Let me write a program.
Copy the Code code as follows:
$url = "Http://maps.google.com/maps/geo?q=beijing&output=csv";
$con = file_get_contents ($url);
$arr = Explode (",", $con);
The 2 and 3 pointers inside the data $arr are the two values that point to the coordinates.
5. Now we just need to consider how to send the location of the IP address to the above URL, and one that makes us happy is that Google support for Chinese is very strong, and can recognize a string of address characters, for example: Beijing and Beijing Netcom is the same, so we do not have to do what conversion, The direct assignment to the above parameter q is OK, then the address is appended to the API key.
6. We can also choose some of the Google Maps style, so that the map function more powerful, such as the addition of satellite maps and so on.
At this point, our map function to the IP query function added, I hope that my attempt to help you.
The above describes the Google Maps API for the IP query to add Google Maps features, including Google Maps API content, I hope to be interested in PHP tutorial friends helpful.