javascript - 使用javascript php laravel在经度和纬度数据库中的条目重复
问题描述
我在这里停留了 24 小时,我一直在尝试获得不同的值。我正在获取每个学生的地址以及经度和纬度。
这是我的观点,我使用了 javascript:
$(document).ready(function() {
$("#dropdown").change(function() {
var selVal = $(this).val();
$("#textboxDiv").html('');
$("#schoolloc").html('');
if(selVal > 0) {
for(var i = 1; i<= selVal; i++) {
$("#textboxDiv").append('<input type="hidden"
value="student'+i+'" name="stud[]" />');
$("#schoolloc").append('<input type="text"
name="studlocation[]" id="studlocation'+i+'" />');
var input = document.getElementById('studlocation'+i+'');
var autocomplete = new google.maps.places.Autocomplete(input);
$("#slat").html('');
$("#slng").html('');
autocomplete.addListener('place_changed', function () {
var place = autocomplete.getPlace();
var lat = place.geometry.location.lat();
var lng= place.geometry.location.lng();
$("#slat").append('<input type="hidden" name="slat" value="'+lat+'" />');
$("#slng").append('<input type="hidden" name="slng" value="'+lng + '" />');
console.log(lat);
});
}
}
});
});
这是我的控制器:
$students = (array)$request->stud;
$locations = (array)$request->studlocation;
for ($i = 0; $i < count($students); $i++){
$hm = new HouseMate;
$hmid = rand();
$hm->hmid=$hmid;
$hm->rId_fk=$renterid;
$hm->person=$students[$i];
$hm->location=$locations[$i];
$hm->$lat=$request->slat;
$hm->lng=$request->slng;
$hm->save();
}
解决方案
推荐阅读
- smartsheet-api - 智能工作表 API - 替换工作表?
- javascript - 如何修复 codacy 警报“通用对象注入接收器”
- rx-java2 - RxJava2 | 使用 .andThen() 链接嵌套的 Completables
- java - 使用 XSL javax.xml.transform.TransformerException 创建 PDF 时出错:org.xml.sax.SAXException
- angularjs - 当对象分配了多个 json 对象时无法过滤
- ios - 为什么没有任何东西发送到我的表格视图?
- linux - 在 Linux 上运行 DialogFlow 查询
- stocktwits - 您可以在不使用 OAuth 的情况下使用 StockTwits api 吗?
- python - 使用 tensorflow 时在异常中包含 tfrecord 名称
- excel - 如果单元格的部分值等于另一列的任何值,则条件格式化单元格