简体   繁体   English

使用Google Maps API旋转标记

[英]Rotate Marker with Google Maps API

I am looking to have markers on the map with a handle that will allow the user to rotate the marker. 我希望在地图上使用带有允许用户旋转标记的手柄的标记。 Then I would like to get the compass heading that the marker is facing. 然后,我想让标记所面对的指南针航向。 Is this possible with the Google Maps API? Google Maps API有可能吗? Are there any good examples? 有什么好的例子吗?

The solution I came up with is to send pre-rotated image to the marker object but instead of physical url a base64 encoded string of the rotated image. 我想出的解决方案是将预先旋转的图像发送到标记对象,但不是物理url,而是旋转图像的base64编码字符串。
so you rotate the image in a hidden div probably outside the map you base64 encode it and then you update the marker with 因此,您可以在可能位于地图外部的隐藏div旋转图像,并对其进行base64编码,然后使用

marker.setIcon({url:(The base64 string here of the image),origin: new google.maps.Point(0,0),anchor: new google.maps.Point(0,0)});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM