简体   繁体   English

谷歌标记动画变化

[英]Google Marker animation change

It there a way to add another animation on Marker which is different than DROP and BOUNCE.有一种方法可以在 Marker 上添加另一个不同于 DROP 和 BOUNCE 的动画。 I would like to enlarge the marker.我想放大标记。 Thanks in advance!提前致谢!

<Marker position={position} animation={window.google.maps.Animation.DROP} />

Since my comment seems to resolve your issue, I'll post this as answer so that others can also see that your question already had a resolution and might help them in the future.由于我的评论似乎解决了您的问题,因此我会将其作为答案发布,以便其他人也可以看到您的问题已经有了解决方案,并且将来可能会对他们有所帮助。 Here's the answer:答案如下:

Google Maps marker animations are only bounce and drop .谷歌地图标记动画只有反弹和下降 If you want to enlarge a marker at runtime, you can use custom Icons instead(a small and a big one).如果你想在运行时放大一个标记,你可以使用自定义图标代替(一个小的和一个大的)。 Then use setTimeout between them.然后在它们之间使用 setTimeout 。 Here's a sample JavaScript fiddle .这是一个示例 JavaScript fiddle

function initMap() {
  var myLatLng = {lat: -25.363, lng: 131.044};

  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 4,
    center: myLatLng
  });

  var marker = new google.maps.Marker({
  icon: 'http://maps.gstatic.com/mapfiles/ridefinder-images/mm_20_orange.png',
    position: myLatLng,
    map: map,
    title: 'Hello World!'
  });

  setTimeout(function(){ marker.setIcon("http://maps.google.com/mapfiles/kml/paddle/orange-blank.png") }, 3000);
}

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

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