Search by Region:
http://api.map.baidu.com/geosearch/v3/local?region=%e5%8e%a6%e9%97%a8&ak=pwinp7mgeptewlpldedv3ur3& geotable_id=*****
Search by Location Center (1800 m from center):
http://api.map.baidu.com/geosearch/v3/nearby?ak=pwinp7mgeptewlpldedv3ur3&geotable_id=***&location= 118.145572,24.49264&radius=1800
The program code is as follows
First to data entry to the Baidu Cloud database
Use the interface to submit location information, coordinate latitude and longitude to Baidu Cloud database of lbs.
Baidu provides visual management of LBS Cloud database:
Http://lbsyun.baidu.com/datamanager/datamanage
A submit data interface has been written by me:
Here is the submission or update of a lbs data.
function ptolbs ($data, $lbsid) {
if ($lbsid <=0) {
$purl = ' http://api.map.baidu.com/geodata/v3/poi/create ';
}else{
$data [' id ']= $lbsid;
$purl = "Http://api.map.baidu.com/geodata/v3/poi/update";
}
$data [' AK ']= "PWINP7MGEPTEWLPLDEDV3UR3";
$data [' geotable_id ']=];//Your database ID
$data [' Coord_type ']= ' 3];
$re = Curlpost ($purl, $data);
$re = Json_decode ($re, true);
if ($re ["status"]==0) {
$lbsid = $re [' id '];
}else{
$lbsid =-1;
}
return $lbsid;
}
function Curlpost ($c _url, $data)
{
$curl = Curl_init (); Start a Curl session
curl_setopt ($curl, Curlopt_url, $c _url); The address to access
curl_setopt ($curl, Curlopt_ssl_verifypeer, 0); Inspection of the source of certification certificate
curl_setopt ($curl, Curlopt_ssl_verifyhost, 1); Check to see if the SSL encryption algorithm exists from the certificate
curl_setopt ($curl, curlopt_useragent, $_server[' http_user_agent ']); Impersonate a browser used by a user
curl_setopt ($curl, curlopt_followlocation, 1); Use automatic jump
curl_setopt ($curl, Curlopt_autoreferer, 1); Automatically set Referer
curl_setopt ($curl, Curlopt_post, 1); Send a regular POST request
curl_setopt ($curl, Curlopt_postfields, $data); Post-Submitted packets
curl_setopt ($curl, Curlopt_timeout, 30); Set timeout limit to prevent dead loops
curl_setopt ($curl, Curlopt_header, 0); Displays the contents of the header area returned
curl_setopt ($curl, Curlopt_returntransfer, 1); Gets the information returned in the form of a file stream
$tmpInfo = curl_exec ($curl); Perform an action
if (Curl_errno ($curl)) {
Echo ' Errno '. Curl_error ($curl);//Catch exception
}
Curl_close ($curl); Close Curl Session
return $tmpInfo; Return data
}
The principle is very simple is through our application of the key band in Curl post to Baidu API, and then Baidu returned to query the corresponding coordinates and data to us.