我正在研究ol3,我有以下鼠标悬停代码,它获取纬度和经度,然后将它们抛到"DIV“上,其id为‘鼠标位置’:
var mousePositionControl = new ol.control.MousePosition({
coordinateFormat: ol.coordinate.createStringXY(4),
projection: 'EPSG:4326',
// comment the following two lines to have the mouse position
// be placed within the map.
className: 'custom-mouse-position',
target: document.getElementById('mouse-position'),
undefinedHTML: ' '
});相应的html div是:
<div class="span6" id="mouse-position"> </div>问题:--我想在"TEXTBOX"上显示这些纬度/经度值,而不是简单地在div上显示它们。
我在"target“字段中简单地将div id更改为textbox的id,但是它没有工作!我还玩弄了value属性,但找不到解决方案。我期待着您的建议,非常感谢您给我时间。:)
注意:上述代码片段的完整代码可以在以下链接中找到:http://openlayers.org/en/master/examples/mouse-position.html
发布于 2015-05-19 20:26:18
如果"textbox“指的是textarea,那么这是行不通的。Textarea需要一个值,而不是"innerHTML类“。
发布于 2020-03-01 23:50:47
试试这个来获取坐标:
var corde = document.getElementsByClassName("custom-mouse-position");
var resultElement=corde[0].innerHTML然后将此值设置为文本框。
https://stackoverflow.com/questions/30308109
复制相似问题