google maps api code to add GOOGLE map function to IP query
Jul 29, 2016 am 08:43 AM1. 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, for example, querying Beijing: http://maps.google.com/maps/geo?q=beijing
3. We can also query 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. So how do we get it? What about the following data? Let me write a program below.
Copy the 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);
Pointers 2 and 3 in data $arr 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 address characters. For example: Beijing and Beijing Netcom are the same, so we don’t need to do any conversion. We just assign it directly to the parameter q above, 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.
The above introduces the google map api code for adding GOOGLE map function to IP query, including the content of google map api. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

11 Best PHP URL Shortener Scripts (Free and Premium)

Working with Flash Session Data in Laravel

Build a React App With a Laravel Back End: Part 2, React

Simplified HTTP Response Mocking in Laravel Tests

cURL in PHP: How to Use the PHP cURL Extension in REST APIs

12 Best PHP Chat Scripts on CodeCanyon

Announcement of 2025 PHP Situation Survey
