image - 如何旋转我们用 js 创建的 img 元素?
问题描述
我为mapbox标记创建了一个img元素。但是当我想旋转它时,它失败了,元素没有变化。
const el = document.createElement('img');
const width = marker.properties.iconSize[0];
const height = marker.properties.iconSize[1];
el.src = marker.properties.image;
el.style.width = `${width}px`;
el.style.height = `${height}px`;
el.style.transform = "rotateZ(130deg)";
new mapboxgl.Marker(el)
.setLngLat(marker.geometry.coordinates)
.setPopup(
new mapboxgl.Popup({offset:[140,100] }) // add popups
.setHTML('<div class="popupWrapper"><div class="top"><img src="../images/turkey.png"
alt="" width="60px" height="55px"><h3 class="vessel_name">'+marker.properties.name+'</h3>
</div><img src="https://photos.marinetraffic.com/ais/showphoto.aspx?
shipid=214197&size=thumb300" alt="marine" width="300px" height="180px"><div
class="vessel_info"><div class="vessel_direction"><p>RU MMK</p><p>IL HAD</p></div></div>
</div>')
)
.addTo(map);
解决方案
推荐阅读
- python - Matplotlib - 向散点图添加图例
- java - 计算数组中七个整数的出现次数
- html - 如何在 Jquery 中调用同一类的更改和单击事件?
- firebase - 有人如何在 Firebase 托管上的多个发行版本之间进行流量拆分
- sql - sql 小提琴表不存在
- javascript - ReactJS,只有最后一个项目 ID 更新
- python - EmptyDataError:没有要从有关流光的文件中解析的列
- sql - Wordpress 单页慢速 SQL 查询
- asp.net-core - 在未经身份验证的 API 请求的情况下如何防止重定向到登录 url?
- reactjs - 单选按钮的反应组件