我想问一下 Laravel HTML Collective。所以我有位置的表格。
所以这张图片来自编辑页面。经纬度是从数据库中获取的。现在我将在搜索位置后更改该值。
我已经制作了谷歌地图 api 函数来获取价值。但现在我很困惑如何更改输入表单。
所以,这是我的功能代码。
function codeAddress(address) {
geocoder.geocode({
'address': address
}, function(results, status) {
if (status == 'OK') {
var lng = results[0].geometry.location.lng();
var lat = results[0].geometry.location.lat();
console.log('lat:' + lat + ', lng:' + lng);
if (marker) { marker.setMap(null); }
marker = new google.maps.Marker({
position: {
lat: lat,
lng: lng
},
map: map,
icon : '{{ url('/images/marker.png') }}'
});
map.setCenter( new google.maps.LatLng(lat, lng) );
} else {
console.log('Geocode was not successful for the following reason: ' + status);
}
});
}
这是我的页面 edit.blade 代码
<div class="row">
<div class="col-lg-6">
{{ Form::label('longitude', 'Longitude') }}
{{ Form::number(
'longitude',
( isset($db) ) ? $db->longitude : null,
array(
'class' => 'form-control'
)
) }}
</div>
<div class="col-lg-6">
{{ Form::label('latitude', 'Latitude') }}
{{ Form::number(
'latitude',
( isset($db) ) ? $db->latitude : null,
array(
'class' => 'form-control'
)
) }}
</div>
</div>