Php calls googlemap?

Source: Internet
Author: User
Php calls googlemap? How does php call googlemap and display the location based on the longitude and latitude sent by the client?


Reply to discussion (solution)

Search for google APIs

Http://wenku.baidu.com/view/704d821ea76e58fafab003b0.html

In this case, the existing code of google needs to share the geographical location of the user to google.
Https://google-developers.appspot.com/maps/documentation/javascript/examples/map-geolocation

Complex, you need an IP address with a latitude and longitude data packet. But few are free, like: http://www.maxmind.com/en/geolocation_landing
Then use

function curIp(){$ip='';if(getenv('HTTP_CLIENT_IP') and strcasecmp(getenv('HTTP_CLIENT_IP'),'unknown')){$ip=getenv('HTTP_CLIENT_IP');}elseif(getenv('HTTP_X_FORWARDED_FOR') and strcasecmp(getenv('HTTP_X_FORWARDED_FOR'),'unknown')){$ip=getenv('HTTP_X_FORWARDED_FOR');}elseif(getenv('REMOTE_ADDR') and strcasecmp(getenv('REMOTE_ADDR'),'unknown')){$ip=getenv('REMOTE_ADDR');}elseif(isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] and strcasecmp($_SERVER['REMOTE_ADDR'],'unknown')){$ip=$_SERVER['REMOTE_ADDR'];}else{$ip='127.0.0.1';}return $ip;}

Obtain the user IP address, convert it from the database to the longitude and latitude, and fill in the JS code of google map.

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: info-contact@alibabacloud.com 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.