Javascript 使用Google Maps setIcon时如何更改标记大小

Javascript 使用Google Maps setIcon时如何更改标记大小,javascript,google-maps,google-maps-api-3,Javascript,Google Maps,Google Maps Api 3,我正在向地图添加标记,最初添加标记时标记很小。但是,我随后将其循环,并将其中一些标记更改为另一个具有相同大小但颜色不同的标记: HTML <div class="row"> <div class="small-6 columns"> <select id="state-select" class=""> <option value="">SELECT A STATE</option>

我正在向地图添加标记,最初添加标记时标记很小。但是,我随后将其循环,并将其中一些标记更改为另一个具有相同大小但颜色不同的标记:

HTML

<div class="row">
  <div class="small-6 columns">
    <select id="state-select" class="">
          <option value="">SELECT A STATE</option>
          <option value="OH">Ohio</option>
          <option value="IL">Illinois</option>
          <option value="IN">Indiana</option>
          <option value="MO">Missouri</option>
          <option value="MI">Michigan</option>
    </select>
  </div>
</div>
<div id="map-canvas"></div>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&libraries=places" type="text/javascript"></script>
但是,标记以较大的尺寸绘制:

如何在使用
setIcon
功能时动态设置标记的大小,以便使这两个标记的大小相同

我用以下方法设定了原始点:

var icon = {
    url: '/img/example_img.png',
    scaledSize: new google.maps.Size(28,50)
}
var marker = new google.maps.Marker({
    position: currLatlng,
    map: map,
    title: thisLocation.Store,
    state: currentState,
    icon: icon
});
然后尝试通过以下方式动态设置点:

$.each(stateMarkerArr, function(index, thisStateMarker) {
    if (thisStateMarker.state == stateCode) {
        var icon = {
            url: '/img/example_img.png',
            scaledSize: new google.maps.Size(28,50)
        }       
        thisStateMarker.setIcon(icon);
        bounds.extend(thisStateMarker.getPosition());           
    } else {
        var icon = {
            url: '/img/example_img2.png',
            scaledSize: new google.maps.Size(28,50)
        }       
        thisStateMarker.setIcon(icon);              
    }
});

您可以使用
google.maps.Icon
对象的
size
scaledSize
属性。见和:


请提供一份证明该问题的报告。这两个图标大小相同。这是没有人真正费心添加的正确代码示例。谢谢你,先生!
$.each(stateMarkerArr, function(index, thisStateMarker) {
    if (thisStateMarker.state == stateCode) {
        var icon = {
            url: '/img/example_img.png',
            scaledSize: new google.maps.Size(28,50)
        }       
        thisStateMarker.setIcon(icon);
        bounds.extend(thisStateMarker.getPosition());           
    } else {
        var icon = {
            url: '/img/example_img2.png',
            scaledSize: new google.maps.Size(28,50)
        }       
        thisStateMarker.setIcon(icon);              
    }
});
var icon = {url:'/img/example_img.png', size: new google.maps.Size(20, 32)};
thisStateMarker.setIcon(icon);