gpt4 book ai didi

javascript - 如何从 OpenLayers 坐标中分离经度和纬度

转载 作者:行者123 更新时间:2023-12-01 00:09:54 25 4
gpt4 key购买 nike

openLayers mousePosition 返回光标位置的坐标 x,y。

var mousePosition = new ol.control.MousePosition({
undefinedHTML: ' ',
projection: 'EPSG:4326',
coordinateFormat: function(coordinate) {
return ol.coordinate.format(coordinate, '{x}, {y}', 6);
},
className: 'ol-mouse-position',
target: document.getElementById('myposition'),
});

提取经度和纬度并使用这两个值在表单中显示的最简单方法是什么?坐标格式的结构是什么?

最佳答案

坐标值是一个普通的 JavaScript 数组。您可以像这样访问值:

var x = coordinate[0];
var y = coordinate[1];

请参阅API docs on Coordinate了解更多详情。

关于javascript - 如何从 OpenLayers 坐标中分离经度和纬度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60148228/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com