4
A
回答
6
虽然@zerkms了一个指向正确的信息,这可能是不够的。我创建了一个fiddle with a working example:帮助。基本配件有:
-
使用地图API放下一个标记
- JavaScript函数在用户点击(这是placeMarker) 防止
- 提交按钮一个javaScript单击处理正常的表单提交并记录标记的当前经纬度信息在隐藏的表单字段
- 正常形态的调用提交
这里是placeMarker代码:
function placeMarker(location) {
if (marker) {
marker.setPosition(location);
} else {
marker = new google.maps.Marker({
position: location,
map: mapInstance
});
}
}
这里是用于处理jQuery代码提交:
$("#submitbutton").on("click", function(e) {
// Prevent normal submit action
e.preventDefault();
// Collect current latlng of marker and put in hidden form field
if (marker) {
$("#latlngfield").val(marker.getPosition().toString());
} else {
$("#latlngfield").val("not entered");
}
// Show results for debugging
submitAction();
// Uncomment this for production and remove submitAction() call
// $("#dataform").submit();
});
这是我使用的表格:
<form id="dataform">
<fieldset>
<legend>Form Information</legend>
<label for="firstnamefield">First Name</label>
<input type="text" name="firstname" id="firstnamefield"><br>
<label for="lastnamefield">Last Name</label>
<input type="text" name="lastname" id="lastnamefield"><br>
<input type="reset" name="reset" value="Clear">
<input type="submit" name="submit" id="submitbutton" value="Submit Data">
<input type="hidden" name="latlng" id="latlngfield">
</fieldset>
</form>
在生产中是不需要的submitAction,我只是想展示一下发生的值:
function submitAction() {
alert("Value of firstname is " + $("#firstnamefield").val());
alert("Value of lastname is " + $("#lastnamefield").val());
alert("Value of latlng is " + $("#latlngfield").val());
}
希望这有助于!
+0
这样做的工作!坦克很多。 – sid606 2012-04-19 20:44:43
+0
辉煌:D也谢谢 – 2012-04-30 03:39:31
相关问题
- 1. 谷歌地图smartinfowindow位置
- 2. 加载位置到谷歌地图 - 谷歌地图v2
- 3. 谷歌地图和jQuery谷歌地图api的位置差异
- 4. jQuery的谷歌地图用户位置
- 5. 谷歌地图用户位置
- 6. 更新表格提交谷歌地图
- 7. 提交谷歌XML网站地图
- 8. 地理位置谷歌地图v2
- 9. 谷歌地图中的地理位置
- 10. 谷歌地图:地理位置援助
- 11. 谷歌地图API(地理位置)
- 12. 地理位置谷歌地图jquery
- 13. 地理位置与谷歌地图V3
- 14. 谷歌地图设置的位置?
- 15. 在谷歌地图上设置位置
- 16. 意图谷歌地图7.0.0的位置
- 17. 谷歌地图当前位置绘图
- 18. 附近的位置谷歌API没有使用谷歌地图
- 19. 使用我的当前位置将谷歌地图实施到谷歌地图
- 20. 用谷歌地图交还交响乐
- 21. 谷歌地图上的当前位置
- 22. 谷歌地图API位置更新
- 23. 谷歌地图比较位置
- 24. 谷歌地图V2让我的位置
- 25. 谷歌在Angularjs的地图位置
- 26. 在谷歌上分享位置地图
- 27. 谷歌地图选择一个位置?
- 28. 谷歌地图当前位置Swift
- 29. OverlayView自动位置谷歌地图V3
- 30. 谷歌地图位置更新
你把它放到隐藏的领域 – zerkms 2012-04-19 11:20:54