简体   繁体   中英

How to change google map's marker size when moving it on map

How to change google map's marker when moving it on the map.

When I move on the map, change marker's size to small and when it's in a fixed position change its size to large.

Thanks.

You could try to do it when the events 'dragstart' and 'dragend' are triggered.

Example:

  google.maps.event.addListener(marker, 'dragstart', function(event) {
    //increase size
    marker.setIcon({url : 'path_to_img', scaledSize: {height: 12 , width: 12}})
  });

  google.maps.event.addListener(marker, 'dragend', function(event) {
   //decrease size
   marker.setIcon({url : 'path_to_img', scaledSize: {height: 64 , width: 64}})
  });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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