如何将值 lat、lng 和地址从 jQuery 谷歌地图函数 (gmaps.js) 传递到 main.html?. 我想获得这些值以及其他值 - 我将在主 html 中获得,我想将所有内容一起写在 MySQL 的表(标记)上,并带有一个保存按钮。任何想法?谢谢!!
//**gmaps.js 函数
function update_ui( address, latLng ) {
$('#gmaps-input-address').autocomplete("close");
$('#gmaps-input-address').val(address);
$('#gmaps-output-latitude').html(latLng.lat());
$('#gmaps-output-longitude').html(latLng.lng());
$('#gmaps-output-address').html(address);
}
//**html 主要代码:
<div id='input'>
<input type='text' id='gmaps-input-address' placeholder='to start, write address...' size="41" />
<div id='gmaps-error'>
</div>
</div>
<div id="gmaps-canvas" style="width:auto; height:250px"></div>
<p>
<!—show current lat, lng and address -->
Latitude: <span id='gmaps-output-latitude'></span> <br/>
Longitude: <span id='gmaps-output-longitude'></span><br/>
Address: <span id='gmaps-output-address'></span><br/>
……
……
<!—start form. (get others values) -->
<label>name<br />
<input class="text" type="text" name="name" id="name" width="100%"/>
</label>
<label>address<br />
<input class="text" type="text" name="address" id="precio" width="100%"/>
</label>
……
<!—here I need to get lat and assign to var-->
<!—here I need to get lng and assign to var -->
<!—here I need to get address and assign to var -->
<!— each one lat, lng , address, in separate vars -->
<!— call to sql to save them in a table -->
<!—end of form (get others values) -->
//**SQL语句:
function insertar($campos){
if($this->con->conectar()==true){
return mysql_query("INSERT INTO markers ( name, precio, lat, lng, address ) VALUES ('".$campos[0]."','".$campos[1]."','".$campos[2]."','".$campos[3]."','".$campos[4]."')");
}
}