我正在使用地理编码控件插件L.GeoSearch(https://github.com/smeijer/L.GeoSearch),我的传单地图的左侧边栏上有一个表单。表单应该将输入提交给php文件,然后通过XMLHttpRequest进行处理。
坐标也必须转移,我对如何将geosearch位整合到表单中有点困惑。有人可以帮助我或提供一些提示吗?
页面:http://app.seedbomb.city/cartodb.html
这是我的地图代码: https://jsfiddle.net/Gopher69/oza08ja4/embedded/result/
done
php处理文件:
https://jsfiddle.net/Gopher69/c692kqov/embedded/result/
<!-- Begin Sidebar!-->
<div id="sidebar">
<h2>Markiere deinen Standort</h2>
<div class="ss-form-container">
<div class="ss-header-image-container">
<div class="ss-header-image-image">
<div class="ss-header-image-sizer"></div>
</div>
</div>
<div class="ss-top-of-page"></div>
<div class="ss-form">
<form onsubmit="" target="_self" id="ss-form" method="POST" action="write_cartodb.php">
<ol style="padding-left: 0" class="ss-question-list" role="list">
<div role="listitem" class="ss-form-question errorbox-good">
<div class="ss-item ss-text" dir="auto">
<div class="ss-form-entry">
<label for="entry_2039516724" class="ss-q-item-label">
<div class="ss-q-title">Bildbeschreibung
</div>
<div dir="auto" class="ss-q-help ss-secondary-text"></div>
</label>
<input type="text" title="" aria-label="caption " dir="auto" id="entry_2039516724" class="ss-q-short" value="" name="beschreibung">
</div>
</div>
</div>
<div role="listitem" class="ss-form-question errorbox-good">
</br>
<input type="file" name="bild" id="uploadfiles" accept="image/*" />
</div>
</div>
</div>
</br>
</br>
<div class="ss-item ss-navigate">
<table id="navigation-table">
<tbody>
<tr>
<td dir="ltr" id="navigation-buttons" class="ss-form-entry goog-inline-block">
<input type="submit" class="jfk-button jfk-button-action " id="ss-submit" value="Senden" name="submit">
</tr>
</tbody>
</table>
</div>
</div>
<!-- End Sidebar!-->
答案 0 :(得分:0)
您可以使用传单map events,例如click
或moveend
,让用户选择该位置。
您可以使用坐标填充表单中的输入字段。此代码将在单击地图时使用坐标更新输入字段:
map.on('click', function(e){
document.getElementById('userlocation').value = e.latlng.lat+','+e.latlng.lng;
});