好吧我试图将BOUNCE动画设置为特定的标记,但每当我调用marker.setAnimation(google.maps.Animation.BOUNCE)方法控制台说“无法读取属性’BOUNCE’未定义”这意味着标记未定义正确?但如果我使用marker.setTitle(‘Bouncing’),标题确实会改变.我做错了什么,这是代码
<script type="text/javascript">
function addMarker(lat,lng,img,title,bounce)
{
var myLatLng = new google.maps.LatLng(lat,lng);
var marker = new google.maps.Marker({
position: myLatLng,map: map,icon: img,title: title,zIndex: 1
});
if(bounce=='set'){marker.setAnimation(google.maps.Animation.BOUNCE);
marker.setTitle('Bouncing');};
}
</script>
PHP脚本
for($i=0;$i<count($losDatos);$i++)
{
$utc=new DateTime($losDatos[$i]['fechaUtc']);
$utc->modify('-'.horarioVerano().' hours');
echo $utc->format("Y-m-d H:i:s");
if($losDatos[$i]['camion']==$camion)
{
$script.="addMarker(".$losDatos[$i]['latitud'].",".$losDatos[$i]['longitud'].",".$losDatos[$i]['img'].",".$losDatos[$i]['nombre'].",'set');";
}else
{
$script.="addMarker(".$losDatos[$i]['latitud'].",".$losDatos[$i]['nombre'].");";
}
}
echo $script;
解决方法
尝试:
marker.setAnimation(google.maps.Animation.BOUNCE)