问题描述
我想在 infoWindow 中显示的输入文本字段中自动显示 lat 和 lng 坐标我点击了地图上的一个地方...这样我就可以在数据库中保存用户的准确标记坐标...
这是来自2个不同的div类。这有可能吗?
<fieldset>
<input type="text" name="userId" id="userId" placeholder="Your userID">
</fieldset>
<fieldset>
<input type="text" name="firstName" id="firstName" placeholder="firsName">
</fieldset>
<fieldset>
<input type="text" name="lastName" id="lastName" placeholder="lastName">
</fieldset>
<fieldset>
<input type="number" name="age" id="age" placeholder="age">
</fieldset>
<fieldset>
<input type="text" name="symptom" id="symptom" placeholder="Symptoms">
</fieldset>
<fieldset>
<input type="text" name="lat" id="lat" placeholder="Latitude">
</fieldset>
<fieldset>
<input type="text" name="lng" id="lng" placeholder="Longitude">
</fieldset>
function initialize() {
var myLatlng = {lat:14.5907332,lng:120.9809674};
var infowindow = new google.maps.InfoWindow();
var map = new google.maps.Map(document.getElementById('map_canvas'),{zoom: 4,center: myLatlng});
// Create the initial InfoWindow.
var infoWindow = new google.maps.InfoWindow(
{content: 'Click the map to get Lat/Lng!',position: myLatlng});
infoWindow.open(map);
// Configure the click listener.
map.addListener('click',function(mapsMouseEvent) {
// Close the current InfoWindow.
infoWindow.close();
// Create a new InfoWindow.
infoWindow = new google.maps.InfoWindow({position: mapsMouseEvent.latLng});
infoWindow.setContent(mapsMouseEvent.latLng.toString());
infoWindow.open(map);
});
我尝试了单击地图并复制坐标并将其放置的手动方法 在我的文本字段上,然后保存到我的数据库中,但这太浪费时间了。。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)