小程序代码:
php服务器端:
$x1=mysql_real_escape_string($_POST['x1']);
$y1=mysql_real_escape_string($_POST['y1']);
$x2=mysql_real_escape_string($_POST['x2']);
$y2=mysql_real_escape_string($_POST['y2']);
$sql="select * from points where lng<'{$x1}' and lng>'{$x2}' and lat<'{$y1}' and lat>'{$y2}'";
$row=$db->getAll($sql);
foreach ($row as $t){
$arr['list'][]=array(
'name'=>$t['cname'],
'id'=>$t['cname'],
'longitude'=>$t['lng'],
'latitude'=>$t['lat']
);
}
echo json_encode($arr);