title: Custom image for Google Maps marker icon using Rails
body: <p>Ruby &amp; rails nuby building one of my first Rails apps. This is also my first ask to Stack Overflow, so please excuse any poor manners (and I welcome feedback on how to be a better user).</p>
  
  <p>I am trying to load an image from my Rails default asset path to use as a custom marker icon for an embedded Google Map. When I simply store the image url in a variable and set that as my icon, my map renders properly with the icon as my marker, but the icon is too big. I'm using the following code to do that:</p>
  
  <pre><code>var icon = "&lt;%= asset_path 'house.png' %&gt;"
  
  var marker = new google.maps.Marker({
    position: homeLatLng,
    map: map,
    title: "Andrew's Home",
    icon: icon,
    animation: google.maps.Animation.DROP
  });
  </code></pre>
  
  <p>However, when I attempt to re-size the image by saving it as a javascript object with a "size" property as per Google's documentation here</p>
  
  <p><a href="https://developers.google.com/maps/documentation/javascript/examples/icon-complex?hl=en" rel="nofollow">https://developers.google.com/maps/documentation/javascript/examples/icon-complex?hl=en</a></p>
  
  <p>I get an error message:</p>
  
  <p>Uncaught SyntaxError: Unexpected identifier</p>
  
  <p>Here's the code I'm using for that:</p>
  
  <pre><code>var icon = {
      url: "&lt;%= image_path 'house.png' %&gt;"
      size: new google.maps.Size(20, 20),
      origin: new google.maps.Point(0, 0),
      anchor: new google.maps.Point(0, 20)
  };
  
  var marker = new google.maps.Marker({
    position: homeLatLng,
    map: map,
    title: "Andrew's Home",
    icon: icon,
    animation: google.maps.Animation.DROP
  });
  </code></pre>
  
  <p>The javascript console in chrome shows me that the error is on this line:</p>
  
  <p>size: new google.maps.Size(20, 20),</p>
  
  <p>and if I comment out that line, I get the same error on the following line (origin: ...) and then the same on the following line (anchor: ...). If I comment out all three and define only the url of the image, then I get the same issue as before with the icon loading but the image too big.</p>
  
  <p>Am I making a typo that I don't see?</p>
  
  <p>What does the "unexpected identifier" error message actually mean?</p>
  
  <p>Thanks for helping me on my learning curve...</p>
  
  <p>Andrew</p>