作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用绘图工具在 google map api v3 上绘制一个矩形。我希望用户能够:
(1) 工作正常,但我需要一些关于 (2) 的帮助。这是我用于 (1) 的代码:
//----------on rectangle complete event
google.maps.event.addDomListener(drawingManager, 'rectanglecomplete', function(rectangle) {
//get the rectangle bounds
document.getElementById("savedata").value =rectangle.getBounds();
//hide draw tool
drawingManager.setOptions({
drawingControl: false
});
//disable draw tool
drawingManager.setDrawingMode(null);
});
最佳答案
为 bounds_changed 添加一个事件监听器到矩形,捕获其中的新坐标。代码:
google.maps.event.addListener(rectangle, "bounds_changed", function() {
document.getElementById("savedata").value =rectangle.getBounds();
});
这里是 an example using the DrawingManager允许您绘制矩形,更改它们并捕获更改后的值。唯一缺少的是 change event (bounds_changed on the rectangle) .
关于javascript - 谷歌地图 API v3 : update rectangle bounds when the shape is dragged or resized,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15497447/
leaflet:一个开源并且对移动端友好的交互式地图 JavaScript 库 中文文档: https://leafletjs.cn/reference.html 官网(英文): ht
我是一名优秀的程序员,十分优秀!