gpt4 book ai didi

javascript - 谷歌无法 map API旋转标记

转载 作者:行者123 更新时间:2023-12-03 10:10:52 27 4
gpt4 key购买 nike

我在 google map 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 度。我怎样才能做到这一点?

最佳答案

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

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

关于javascript - 谷歌无法 map API旋转标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30117374/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com