Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用的示例来自:Google-Maps-for-Rails-Marker-dragging
我有一个由脚手架创建的页面视图。单击保存后,如何从 JavaScript 获取并将新位置保存到数据库中:地址、经度、纬度。
您需要为您的标记添加一个侦听器:
google.maps.event.addListener(marker, 'dragend', function() { var latitude = marker.getPosition().lat(); var longitude = marker.getPosition().lng(); // use Ajax to save latitude, longitude in the database }