如何使用openlayers3在文本框中显示地图鼠标悬停值?

问题描述 投票:1回答:2

我正在研究ol3,并且具有以下鼠标悬停代码,该代码将获取经度和纬度,然后将其置于ID为“ mouse-position”的“ DIV”上:]

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">&nbsp;</div>

问题:我想显示这些纬度/经度值显示在“ TEXTBOX”上,而不是简单地在div上显示它们。

我简单地在“目标”字段中将div ID更改为文本框的ID,但这没有用!我也玩过value属性,但是找不到解决方案。我很期待这些建议,非常感谢您的宝贵时间。 :)

NOTE:这些片段的完整代码可以在以下链接中找到:http://openlayers.org/en/master/examples/mouse-position.html

javascript openlayers-3
2个回答
0
投票

如果用“文本框”表示textarea


0
投票

尝试获取坐标:

© www.soinside.com 2019 - 2024. All rights reserved.