我在下面通过axios从Vue向控制器发送参数。
getMarkers: function() {
let bounds = this.map.getBounds();
let southWest = bounds.getSouthWest();
let northEast = bounds.getNorthEast();
axios.get('/ajax', {
params: {
fromLat: southWest.lat()-0.05,
toLat: northEast.lat()-0.05,
fromLng: southWest.lng()+0.05,
toLng: northEast.lng()+0.05,
}
}).then((response) => {
this.estates = response.data;
this.updateMarkers();
});
},
然后在控制器中获取此数据。
public function ajax(Request $request){
$fromLat = $request->get('fromLat');
$toLat = $request->get('toLat');
$fromLng = $request->get('fromLng');
$toLng = $request->get('toLng');
$data = \DB::table('allestates')
->where('lat', '>', $fromLat)
->where('lat', '<', $toLat)
->where('lng', '>', $fromLng)
->where('lng', '<', $toLng)
->get();
$response = response()->json($data);
return $response;
}
问题从这里开始。当我检查端点(即“ /ajax
”)时,出现错误。
非法运算符和值组合。
这是因为$fromLat
等在当时为空吗?检查image.
但是地图和标记工作正常。不过,直到我移动地图并查看所有标记,我才能看到页面中的数据。然后数据也在页面中可见。但是端点仍然给出错误。
感谢您的帮助!
答案 0 :(得分:0)
The position modes (fst_posmode) for the F_PREALLOCATE command indicate how to use the offset field.
The modes are as follows:
F_PEOFPOSMODE Allocate from the physical end of file.
F_VOLPOSMODE Allocate from the volume offset.
尝试一下
答案 1 :(得分:0)
您可以检查null或某些值,然后执行条件查询:
$query = \DB::table('allestates');
if ($fromLat != NULL && $fromLat != ''){
$query->where('lat', '>', $fromLat);
}
if ($toLat != NULL && $toLat != ''){
$query->where('lat', '>', $toLat);
}
if ($fromLng != NULL && $fromLng != ''){
$query->where('lng', '>', $fromLng);
}
if ($toLng != NULL && $toLng != ''){
$query->where('lng', '>', $toLng);
}
$result = $query->get();