Preface:How to get the coordinates of the current mouse in the Vue project? Here is a method to share. Result: Implementation steps:1. Import relevant documents import MousePosition from 'ol/control/MousePosition'; import {createStringXY} from 'ol/coordinate'; 2. Generate a map var layers = [ //Dark blue background new TileLayer({ source: new XYZ({ url: "https://map.geoq.cn/ArcGIS/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x}", }), }), ]; this.map = new Map({ layers: layers, target: "map", view: new View({ center: this.center, projection: this.projection, zoom: this.centerSize, maxZoom: 17, minZoom: 5, extent: [ 73.32783475401652, 3.33795, 135.16017906160056, 53.83501005646246, ], }), }); 3. Add mouse events var mousePositionControl = new MousePosition({ coordinateFormat: createStringXY(6), //Get the location projection: 'EPSG:4326', className: 'custom-mouse-position', target: document.getElementById('mouse-position'), //Put the position data there undefinedHTML: ' ' }); this.map.addControl(mousePositionControl); 4. Add on the page <div id="map" class="map" ref="imageDom"> Position div <div id="mouse-position" style=" color: #fff; position: absolute; bottom:10px; right:10px; z-index: 10000000; width: 200px; line-height: 30px; background: rgba(0,0,0,0.5); "></div> </div> This is the end of this article about vue+openlayer5 getting the coordinates of the current mouse. For more relevant vue+openlayer5 mouse coordinates content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: Three uses and differences of MySQL not equal
>>: Introduction to the use of select optgroup tag in html
ElementUI implements the table list paging effect...
This is because the database server is set to aut...
When playing music, the lyrics will gradually fil...
After setting the table width in the page to width...
The best thing you can do for your data and compu...
Table of contents 1. Four concepts 1. JavaScript ...
MySQL 8.0 compressed package installation method,...
Configure Git environment in Docker At work, I en...
In the previous article "Understanding UID a...
Preface Hello everyone, this is the CSS wizard - ...
This article uses examples to describe the add, d...
Table of contents 1. Install Docker 2. Install Gi...
Table of contents 1. Background knowledge 1. Intr...
We all know that after the MySQL database is inst...
Preface When a Linux is fully set up, you can use...