Closed rddewan closed 4 years ago
Hi How do i load map from ajax post request
//route Route::post('/gps/map/get_map','GpsLog\MapController@getMap');
//controller /*
get map by filter request */
public function getMap(Request $request){ $user = Auth::user();
$data = GpsLog::where('company_id', $user->company_id) ->where('user_name',$request->deviceId) ->where('current_year',$request->year) ->where('current_month',$request->month) ->where('current_day',$request->day) ->orderBy('id', 'desc') ->get(); return response()->json([ 'latitude' => $data->latitude, 'longitude' => $data->longitude ]);
}
//view
<div id="#map-holder" style="width: 100%; height: 80%;"> {!! Mapper::render() !!} </div> <script type="text/javascript"> $.ajaxSetup({ headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') } }); $("#search_device").click(function () { $.ajax({ url: '/gps/map/get_map', type : 'POST', data: { 'deviceId' : $("#select_user option:selected").val(), 'year' : $("#select_year option:selected").val(), 'month' : $("#select_month option:selected").val(), 'day' : $("#select_day option:selected").val() }, success:function (data) { maps[0].map.setCenter({lat: data.latitude, lng: data.longitude}); }, error:function (xhr, status, error) { let responseText = JSON.parse(xhr.responseText),data = responseText['errorInfo']; swal({ title: "Error !", text: "Status: " +xhr.status +" - Message: " + data + " - Error: " + error, type: "error", button: "OK", }); } }) }) </script>
Hi there,
Try looking over the following: https://github.com/bradcornford/Googlmapper/issues/91
Hi How do i load map from ajax post request
//route Route::post('/gps/map/get_map','GpsLog\MapController@getMap');
//controller /*
get map by filter request */
public function getMap(Request $request){ $user = Auth::user();
}
//view