1. Before using Google API, we need to apply for a key first and add it to the end of the URL as a unique identifier.
2. There is an address in the Google Maps API that can be used to query detailed information of a certain location, such as querying 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, if we need csv data, then the address becomes http://maps.google.com/maps/geo?q=beijing&output =csv
4. In this way, we get 4 pieces of data. The first is the http return address, the second is the accuracy, and the last two are coordinates. If we know the left side, we can locate a certain point. , then how do we get the subsequent data? Let me write a program below.
Copy code The code is as follows:
$url = "http://maps.google.com/maps/geo? q=beijing&output=csv";
$con = file_get_contents($url);
$arr = explode(",",$con);
2 in data$arr The and 3 pointers are the two values of the coordinates pointed to.
5. Now we only need to consider how to pass the queried IP address to the URL address above. Another thing that makes us happy is that Google has strong support for Chinese and can recognize a string of addresses. Characters, for example: Beijing and Beijing Netcom are the same, so we don’t need to do any conversion, just assign it directly to the above parameter q, and then add the api key after the address.
6. We can also choose some styles of Google Maps to make the map function more powerful, such as adding satellite maps, etc.
At this point, our map function has been added to the IP query function. I hope my attempt will be helpful to everyone.
http://www.bkjia.com/PHPjc/322340.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322340.htmlTechArticle1. Before using google api, we need to apply for a key first and add it to the end of the url as a unique identifier. 2. There is a place in the Google Maps API where you can query the detailed information of a certain place...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn