Code for adding the GOOGLE Map function to IP address query. 1. before using googleapi, we need to apply for a key and add it to the url as a unique identifier. 2. the google Map api contains a location where detailed information about a location can be queried. before using google APIs, we need to apply for a key and add it to the url as a unique identifier.
2. google Map api contains an address that can query the details of a location, such as query Beijing: http://maps.google.com/maps/geo? Q = beijing
3. we can also add a parameter after the above address to let it output the data we want, for example, we need csv data, then the address becomes a http://maps.google.com/maps/geo? 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, in addition, it can recognize a string of address characters. for example, Beijing and Beijing Netcom are the same, so we don't need to perform any conversions. just assign the value to the above parameter q, then the address is followed by the api key.
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.
Http://www.bkjia.com/PHPjc/322340.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/322340.htmlTechArticle1. before using google APIs, we need to apply for a key and add it after the url as a unique identifier. 2. there is a location in the google Map api that can query the details of a location...