Google Maps API code for adding Google Maps features to IP queries

Source: Internet
Author: User
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:
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
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://";
$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.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.