title: allow user to move marker position back (z-index?) in google maps custom map
body: <p>I would like to allow user to be able to move order of custom google maps marker on a click inside an InfoWindow.  This is to overcome issue of overlapping markers.  I have considered other solutions (move lat/lon, marker clusters, "spider markers"). </p>
  
  <p><img src="https://i.stack.imgur.com/LECp5.jpg" alt="enter image description here"></p>
  
  <p>My code has 2 issues: 1) jquery listener not working 2) but more important how to implementing change of z-index (or other technique?) and redisplay.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
  
      &lt;style&gt;
      #map-canvas, #side-bar {        
      height: 500px;
      width: 600px;        
      }
  
      &lt;/style&gt;
      &lt;script src="http://maps.googleapis.com/maps/api/js" type="text/javascript"&gt;&lt;/script&gt;           
      &lt;script src="../jquery/jquery.js" type="text/javascript"&gt;&lt;/script&gt; 
      &lt;script type="text/javascript"&gt;
  
  
  // scoping for jquery
  $( document ).ready(function() {
  
          "use strict";
  
          // variable to hold a map
          var map;
  
          // variable to hold current active InfoWindow
          var activeInfoWindow ;      
  
          // ------------------------------------------------------------------------------- //
          // initialize function      
          // ------------------------------------------------------------------------------- //
            function initialize() {
  
              // ------------------------------------------------------------------------------- //
              // LISTENER ON CLICK EVENT
              // ------------------------------------------------------------------------------- //
              $( "a" ).on( "click", function() {              
                  alert("got here!");
                  // do something to change z-index of this marker
                  //...
                  // my_index = my_index-1; 
                  //...
                  return false;
              });
  
              // map options - lots of options available here 
              var mapOptions = {
                zoom : 5,
                draggable: true,
                center : new google.maps.LatLng(44.960, -93.100),
                mapTypeId : google.maps.MapTypeId.ROADMAP
              };
  
              // create map in div called map-canvas using map options defined above
              map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
  
              // define two Google Map LatLng objects representing geographic points
              var stPaul          = new google.maps.LatLng(44.95283,-93.08925);
              var minneapolis     = new google.maps.LatLng(44.97984,-93.26620);
  
              // place two markers
              fnPlaceMarkers(stPaul,"St Paul");
              fnPlaceMarkers(minneapolis,"Minneapolis");          
            }
  
  
          // ------------------------------------------------------------------------------- //
          // create markers on the map
          // ------------------------------------------------------------------------------- //
          function fnPlaceMarkers(myLocation,myCityName){
  
              var marker = new google.maps.Marker({
                  position : myLocation
              });
  
              // Renders the marker on the specified map
              marker.setMap(map); 
  
              // create an InfoWindow
              var infoWnd = new google.maps.InfoWindow();         
  
              // add content to your InfoWindow
              infoWnd.setContent('&lt;div class="scrollFix"&gt;' + 'Welcome to ' +  myCityName + '&lt;br/&gt;&lt;a href="#"&gt;Click&lt;/a&gt; to move this marker to the back&lt;/div&gt;');
  
              // add listener on InfoWindow - close last infoWindow  before opening new one 
              google.maps.event.addListener(marker, 'click', function() {
  
                  //Close active window if exists - [one might expect this to be default behaviour no?]               
                  if(activeInfoWindow != null) activeInfoWindow.close();
  
                  // Open InfoWindow
                  infoWnd.open(map, marker);
  
                  // Store new open InfoWindow in global variable
                  activeInfoWindow = infoWnd;
              });                             
          }
  
  
          // ------------------------------------------------------------------------------- //
          // initial load
          // ------------------------------------------------------------------------------- //       
          google.maps.event.addDomListener(window, 'load', initialize);
  
  });  // end query
  
  
      &lt;/script&gt;
          &lt;div id="map-canvas"&gt;&lt;/div&gt;
    &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>