Zap*_*ica 1 html javascript forms jquery google-maps http-post
是否可以将google maps api集成到html表单中,用户可以通过坐标的形式选择特定的针点位置并将其与表单一起提交?
我正在使用带有Razor视图的asp.net,但我怀疑无论如何都会影响这个问题的答案.
我查看了https://developers.google.com/maps/documentation/javascript/tutorial,似乎无法使用maps api作为表单输入.除非我是盲目的.
添加一个可拖动标记并将lat/lng值存储在dragend(事件文档)上的隐藏输入中.
// Place a draggable marker on the map
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
draggable:true,
title:"Drag me!"
});
//get marker position and store in hidden input
google.maps.event.addListener(marker, 'dragend', function (evt) {
document.getElementById("latInput").value = evt.latLng.lat().toFixed(3);
document.getElementById("lngInput").value = evt.latLng.lng().toFixed(3);
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3627 次 |
| 最近记录: |