【发布时间】:2016-07-26 16:13:15
【问题描述】:
我的视图中有一个由复选框、一些文本字段和选择组成的表单。
在同一页面上,我有 googlemap 地理编码器。位置 lat&lng 保存在 javascript 的变量中。
function geocodeAddress(geokodiranje, resultsMap) {
var address = document.getElementById('address').value;
var location = {};
geokodiranje.geocode({'address': address}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
location.lattitude = results[0].geometry.location.lat();
location.longitude = results[0].geometry.location.lng();
resultsMap.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: resultsMap,
position: results[0].geometry.location
});
lat = location.lattitude; //THIS IS MY LAT
lng = location.longitude; //THIS IS MY LNG
} else {
alert('Geocode failed for reason: ' + status);
}
});
}
在我的控制器中,我有 POST 功能可以将表单保存在数据库中。
$input = Request::all();
Blogpost::create($input);
return redirect('other');
在我的数据库中,我有 lat 和 lng 列,我想添加变量,问题是我无法将这 2 个变量添加到控制器中的 $input 变量中。请帮帮我! :)
【问题讨论】:
标签: javascript php google-maps laravel-5 request