Google Maps API Zoom in and out marke size change

2019-07-25 11:10发布

google.maps.event.addListener(google_map, 'zoom_changed', function() {
var z = google_map.getZoom();

_.each(map_shapes, function(s) {

    if (! $.isFunction(s.shape.getPosition)) return;

    var w = s.shape.getIcon().size.width;
    var h = s.shape.getIcon().size.height;

    s.shape.setIcon(new google.maps.MarkerImage(
        s.shape.getIcon().url, null, null, null, new google.maps.Size(
            w - Math.round(w / 3 * (last_zoom - z)),
            h - Math.round(h / 3 * (last_zoom - z)))
        )
    );

});

last_zoom = z;
});

I am using this code to resize my marker when someone zooms in and out, but it makes the icon bigger as you zoom out, and smaller as you zoom in. I want the opposite of that.

I am using googles Maps API 3.

I've tried a few different combinations but can't seem to get it to work.

0条回答
登录 后发表回答