javascript - 采取经纬度openlayers
问题描述
大家好,我有一个问题,我正在创建一个地图,在其中创建两个指针(起点 - 目的地),我可以根据文本框中的地址找到点。与在几个位置一样,地址未定义我想要做的是在用户拖动指针时获取指针的纬度和经度。到目前为止,我只能使指针移动,但无法恢复它们的经纬度。我分享了我正在执行该部分的代码部分。
//**** para mover el puntero Origen *****
var modifyOrigen = new ol.interaction.Modify({source: sourceOrigen});
map.addInteraction(modifyOrigen);
function addInteractions(e) {
drawOrigen = new ol.interaction.Draw({
source: sourceOrigen,
type: iconoParadaCoche.value
});
map.addInteraction(draw);
snapOrigen = new ol.interaction.Snap({source: sourceOrigen});
map.addInteraction(snapOrigen);
}
//**** para mover el puntero Destino *****
var modifyDestino = new ol.interaction.Modify({source:
sourceDestino});
map.addInteraction(modifyDestino);
function addInteractions() {
drawDestino = new ol.interaction.Draw({
source: sourceDestino,
type: iconoParadaCoche.value
});
map.addInteraction(drawDestino);
snapDestino = new ol.interaction.Snap({source: sourceDestino});
map.addInteraction(snapDestino);
}
解决方案
您应该能够在 modifyend 事件中获取坐标
modifyOrigen.on('modifyend', function(evt) {
console.log(evt.features.item(0).getGeometry().getCoordinates());
});
推荐阅读
- swift - 使用swift在scrollview内的stackview中更改uibutton中的标题
- html - 如何阻止此文本移过此图像?
- docker - Firefox headless 不能在 Docker 中以非 root 用户身份工作
- javascript - InvalidStateError:无法在“IDBDatabase”上执行“事务”:数据库连接正在使用 ios safari 关闭
- ios - 等效于 iOS AVPlayer 的 exoplayer 中的 getBufferedPosition()
- django - Django 权限:基于逻辑的自定义检查
- reactjs - 使用 cookie 在 2 个反应 Web 应用程序之间共享身份验证
- javascript - 是否有一种 javascript 方法可以告诉我们输入范围滑块值是上升还是下降?
- python - 如何通过将它们相乘来修复整数(python pandas)
- git - github上的隐藏文件?