簡體   English   中英

我想通過輸入標簽設置傳單標記的旋轉值

[英]I want to set a rotation value for marker of leaflet via an input tag

我有一個類型范圍的HTML輸入標記,我想用它來設置傳單標記的rotationAngle的值。 此外,當用戶更改<input>的值時,rotationAngle必須更新。

我也使用https://github.com/bbecquet/Leaflet.RotatedMarker但無法使用用戶輸入設置值。

我希望當輸入標簽值改變時,rotationAngle繼續改變。

您可以使用setRotationAngle(newAngle)方法更新rotationAngle

 var map = L.map('map').setView([50.5, 30.5], 18); L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors' }).addTo(map); var marker = L.marker([50.5, 30.5], { rotationAngle: 0 }).addTo(map); function updateAngle(input) { marker.setRotationAngle(input.value); } 
 #map { position: absolute; top: 35px; left: 0; width: 100%; height: 80% } 
 <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" /> <script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script> <script src="https://cdn.jsdelivr.net/npm/leaflet-rotatedmarker@0.2.0/leaflet.rotatedMarker.min.js"></script> <input type="number" value="0" min="-360" max="360" onblur="updateAngle(this)"> <div id="map"></div> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM