Maps API v3 SVG markers increase in size0ff

Increate marker icon size every time a marker is added to the map

by freedawirl

HTML

<script src="http://maps.googleapis.com/maps/api/js?sensor=false"></script>
<div id="map-canvas"></div>

CSS

#map-canvas { 
height: 400px; 
}

JavaScript

var map;
var polyLine;
var polyOptions;
var iconSize = 1;

function initialize() {
    
    var mapOptions = {
        zoom: 10,
        mapTypeId: google.maps.MapTypeId.ROADMAP,
        center: new google.maps.LatLng(30.267200, -97.743100)
        
    };

    map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
    
    google.maps.event.addListener(map, 'click', function(event) {

        addPoint(event);
    });
}

function addPoint(event) {

    var icon = {
        
        path: "M-20,0a20,20 0 1,0 40,0a20,20 0 1,0 -40,0",
        fillColor: '#FF0000',
        fillOpacity: 1,
        anchor: new google.maps.Point(0,0),
        strokeWeight: 2,
        scale: iconSize
    }

    var marker = new google.maps.Marker({
        position: event.latLng,
        map: map,
        draggable: false,
        icon: icon,
        zIndex : -20
    });
    
    map.panTo(event.latLng);
    
    iconSize += 0;
}

initialize();