I have made an IP address query page and can find the locations of many domestic IP addresses in detail. I upgraded this page a few days ago and added a map feature to it. This feature comes from the ap
I have made an IP address query page and can find the locations of many domestic IP addresses in detail. I upgraded this page a few days ago and added a map feature to it. This feature comes from the ap
1. Before using google APIs, we need to apply for a key, Hong Kong server, and add it to the url as a unique identifier.
2. The google map api contains an address that can query the detailed information of a specific location, for example, the following :? Q = beijing
3. We can add a parameter next to the above address to output the desired data. For example, if we need csv data, the address becomes? Q = beijing & output = csv
4. in this way, we get four pieces of data. The first is the http return address, the second is the precision, and the second is the coordinate. If we know that we can not locate a certain point on the left, how can we get the following data? Next I will write a program.
The Code is 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 in data $ arr are the two coordinate values.
5. now we only need to consider how to pass the ip address to the url address above. What makes us happy is that google has a strong support for Chinese, the Hong Kong server can also recognize a string of address characters. For example, Beijing and Beijing Netcom are the same, so we don't need to perform any conversions, directly assign the value to the above parameter q, and then add the api key to the address.
6. We can also select some google map styles to make the map more powerful, such as adding satellite maps.
So far, our map function has added the IP address query function. I hope my attempt will be helpful to you.