谷歌无法映射api旋转标记

时间:2015-05-08 06:42:08

标签: javascript google-maps google-maps-api-3 rotation

我在google maps api上旋转我的标记时遇到了一些问题。我目前在做:

<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>

但这不值得工作,我知道标题是50度,你可以在“旋转”中看到。我怎么能这样做?

1 个答案:

答案 0 :(得分:1)

您需要稍微更改标记结构以进行旋转:

&#13;
&#13;
        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);
&#13;
<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>;
&#13;
&#13;
&#13;