title: Change google maps location onclick
body: <p>I found a great code on web and I am trying to move the marker to another location with a button. I think I need to trigger variable "targetLocation" with a click event but I couldn't find out how. Or should I create variables like targetlocation2 and marker2 ?</p>
  
  <p>location1: 41.118555", 28.2743889</p>
  
  <p>location2: 38.9152733, -111.6676686</p>
  
  <p>html:</p>
  
  <pre><code>&lt;a href="#location1"&gt;Address 1&lt;/a&gt;
  &lt;a href="#location2"&gt;Address 2&lt;/a&gt;
  </code></pre>
  
  <p>code:</p>
  
  <pre><code>if ($("#map .google-maps").length) {
  var directionsService = new google.maps.DirectionsService();
  var directionsDisplay = new google.maps.DirectionsRenderer();
  var targetLocation = new google.maps.LatLng("41.118555", "28.2743889");
  
  var myOptions = {
      center: targetLocation,
      mapTypeId: google.maps.MapTypeId.ROADMAP,
      zoom: 13,
      scrollwheel: false,
      streetViewControl: false,
      mapTypeControl: false,
      disableDoubleClickZoom: true,
      styles: [
      {
          featureType: "all",
          stylers: [
          {saturation: -100}
          ]
      }
      ]
  }
  
  var map = new google.maps.Map($("#map .google-maps")[0], myOptions);
  directionsDisplay.setMap(map);
  
  var marker = new google.maps.Marker({
      position: targetLocation,
      map: map,
      icon: "marker.png",
      visible: true
  });
  </code></pre>
  
  <p>}</p>