title: Google Maps marker colour based on database value
body: <p>I wish the marker colour on a Google Map to change if the <code>BusinessType</code> field in the database for that marker is a certain value.</p>
  
  <p>Currently my map can be filtered for different business types through values in a listbox. The values are <code>All</code> (to include everything), <code>Type1</code> and <code>Type2</code>.</p>
  
  <p>I've used the following to change the marker from the default to a custom graphic which works well but it uses it for all markers, as expected.</p>
  
  <pre><code>var marker = new google.maps.Marker({
      map: map,
      position: latlng,
      icon: 'BlueMarker.png'
  });
  </code></pre>
  
  <p>I've tried various if statements both for the <code>marker</code> variable as a whole and just for the <code>icon</code> part of the variable but I can't get it to use a different graphic based on the value in the <code>BusinessType</code> variable.</p>
  
  <p>Can somebody point me in the right direction please?</p>
  
  <p>This is the entire function for the marker:</p>
  
  <pre><code>function createMarker(latlng, name, add1, add2, add3, town, county, address, businesstel, website) {
  
     var html = "&lt;b&gt;" + name + "&lt;/b&gt; &lt;br/&gt;" + add1 + " &lt;br/&gt;"  + add2 + " &lt;br/&gt;" + add3 + " &lt;br/&gt;" + town + " &lt;br/&gt;" + county + " &lt;br/&gt;"
     + address + " &lt;br/&gt;" + " &lt;br/&gt;"+ " &lt;b&gt;" + "Tel: " + businesstel + " &lt;/b&gt; &lt;br/&gt;" + "&lt;a href="+"http://www.website.com&gt; &lt;font color="+"blue&gt;"+ website +"&lt;/font&gt; &lt;/a&gt; &lt;br/&gt; &lt;br/&gt;";
  
  var marker = new google.maps.Marker({
      map: map,
      position: latlng,
      icon: 'BlueMarker.png'
    });
  
  google.maps.event.addListener(marker, 'click', function() {
      infoWindow.setContent(html);
      infoWindow.open(map, marker);
    });
  
  markers.push(marker);
  }
  </code></pre>
  
  <p>Thanks</p>