javascript - 如何在 Openlayer 5 和 vanilla js 中使用 MousePosition?
问题描述
我的代码有什么问题?我想得到坐标mousePosition
。我使用openlayer v5。
var map = new ol.Map({
target: 'map2',
layers: [
new ol.layer.Tile({
source: new ol.source.OSM()
})
],
view: new ol.View({
center: ol.proj.fromLonLat([116.041389, 3.073093]),
zoom: 7.3
})
});
var mousePositionControl = new ol.MousePosition({
coordinateFormat: createStringXY(2),
projection: 'EPSG:4326',
className: 'custom-mouse-position',
target: document.getElementById('mouse-position'),
undefinedHTML: ' '
});
执行上面的代码会得到一个
“ReferenceError:未定义 createStringXY”错误。
解决方案
推荐阅读
- r - 如何在特定位置拆分 .txt 文件并将每个部分作为表格导入 r
- angularjs - Jasmine AngularJs 如何访问控制器的属性
- xcode - 使用 xcode swift 3 从 osx/cocoa 应用程序获取当前位置
- components - 是否有仅适用于 amp-story 的组件列表?
- android - android应用程序防止sql文件进行逆向工程
- hue - Hue - 限制用户创建查询
- bash - 是否可以在不对输出文件进行排序的情况下使用 Grep、Sed 或 Awk 或 bash 脚本?
- flutter - 如何在 Flutter 中实现 CheckBox?
- javascript - 我在将服务数据推送到 ANGULAR 数组时遇到问题
- cordova - Ionic Cordova 在每次构建时都发现了插件