在谷歌地图 api v3 上旋转 .gif 图像?
问题描述
我在这个问题上找到了很多答案,但没有一个在使用 .gif 图像而不是标记时有效.要使用 .gif 图像(以及动画 gif),我使用代码(有效)
I find lots of answers on this question but not one that works when using .gif images and not markers. To use .gif images (and also animated gifs) I use code (which works)
//对于没有使用过.gif的人来说,'optimized: false'这一行很关键
//for anyone who has not used .gif, the line 'optimized: false' is critical
我现在要做的是旋转 gif 图像(到指定的角度,而不是恒定的旋转 [我可以做 gif 动画]).尽管使用 'store_id: mkrID' 为图像设置 ID,之前创建了 var mkrID,但我可以使用代码 marker.get('store_id') 将其读回,所以我知道它已被设置.我无法使用 document.getElementById 访问图像.我也不能让任何谷歌地图 API 旋转示例代码工作.我发现的示例似乎适用于 v2 或与谷歌地图自己的标记有关,而不是使用 gif 的自定义图像.
What I want to do now is rotate the gif image (to a specified angle, not a constant rotate [that I can do as animated gif]). Dispite setting the ID for the image with 'store_id: mkrID,' var mkrID being previously created, and I can read it back with code marker.get('store_id') so I know it's been set. I cannot access the image with document.getElementById. nor can I get any of the google maps API rotate eample code to work either. Examples I find seem to be for v2 or relate to google maps own markers, not custom images using a gif.
有人可以在谷歌地图中旋转 gif 图像吗?
Has anyone been able to rotate a gif image in a google map?
推荐答案
store_id"标记的属性不允许您访问包含图像的 DOM 元素.如果每个标记都有一个唯一的图标,则可以使用 JQuery 的 URL 获取它,然后对其应用 CSS 转换:
The "store_id" property of the marker doesn't give you access to the DOM element which contains the image. If you have a unique icon for each marker, you can grab it using its URL with JQuery, then apply a CSS transform to it:
注意:这仅适用于带有 optimized: false
- 概念证明小提琴
- 概念证明小提琴旋转 .png 图像
代码片段:
这篇关于在谷歌地图 api v3 上旋转 .gif 图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!