简体   繁体   English

谷歌无法映射api旋转标记

[英]google can't maps api rotate marker

Im having some problem rotating my marker at google maps api. 我在Google Maps API旋转标记时遇到一些问题。 Im currently doing: 我目前正在做:

<script>
function initialize() {
    var mapProp = {
        center: new google.maps.LatLng(51.508742, -0.120850),
        zoom: 4,
        minZoom: 2,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map"), mapProp);
    var myLatlng = new google.maps.LatLng(-51.508742, -0.120850);

    var image = 'http://wcdn1.dataknet.com/static/resources/icons/set73/f3eef3d2.png';
    var marker = new google.maps.Marker({
        position: myLatlng,
        icon: {
            path: google.maps.SymbolPath.BACKWARD_OPEN_ARROW,
            scale: 10
        },
        rotation: 50,
        map: map
    });
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>

But this dosn't work sadly, I know the heading and that is 50 degrees as you can see in the "rotate". 但这并不令人遗憾,我知道航向,并且在“旋转”中可以看到是50度。 How can I do this? 我怎样才能做到这一点?

You need to change Marker structure a bit for rotation: 您需要稍微改变Marker结构以进行旋转:

  function initialize() { var mapProp = { center: new google.maps.LatLng(51.508742, -0.120850), zoom: 4, minZoom: 2, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map"), mapProp); var myLatlng = new google.maps.LatLng(-51.508742, -0.120850); var image = 'http://wcdn1.dataknet.com/static/resources/icons/set73/f3eef3d2.png'; var marker = new google.maps.Marker({ position: myLatlng, icon: { path: google.maps.SymbolPath.BACKWARD_OPEN_ARROW, scale: 10, rotation: 50 }, map: map }); } google.maps.event.addDomListener(window, 'load', initialize); 
 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script> <div id="map" style="width:500px;height:500px;"></div>; 

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

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