title: Mapbox Icon-Image Dynamic Symbol (icon) Loading with Sprite
body: <p>I am trying to do something I feel is very simple, yet seems that I am clearly misunderstanding a crucial piece of the mapbox <code>addlayer</code> feature.</p>
  <p><strong>The Goal</strong></p>
  <p>Create dynamically identified icons, based on a features data value (e.g. geojson feature data vale <code>title: &quot;walmart&quot;</code>). Essentially just adding dynamic store icons from the sprite image when those locations are queried via tilequery. <a href="https://i.stack.imgur.com/XJ0RI.png" rel="nofollow noreferrer">picture representation here</a></p>
  <p><strong>The problem</strong></p>
  <p>I keep getting an error when trying to use the sprite values from the style. Error: <code>util.js:349 Image &quot;airport-11&quot; could not be loaded. Please make sure you have added the image with map.addImage() or a &quot;sprite&quot; property in your style. You can provide missing images by listening for the &quot;styleimagemissing&quot; map event.</code></p>
  <p>I see tons of resources talking about sprites, but none discuss how to exactly implement them in this fashion. I have even tried querying the sprite and then adding the values using dot notation to access sprite values. This gives an error of &quot;undefined&quot; and invalid value.</p>
  <p>Example code:</p>
  <pre><code>      map.addLayer({
      id: &quot;tilequery-points&quot;,
      type: &quot;symbol&quot;,
      source: &quot;tilequery&quot;, // Set the layer source
      layout: {
        &quot;icon-image&quot;: [
          &quot;match&quot;,
          [&quot;get&quot;, &quot;title&quot;],
          [&quot;HEB&quot;],
          &quot;H-E-B_logo&quot;,
          [&quot;Pilot Flying j&quot;],
          sprite.Pilot_Travel_Centers_logo,
          // &quot;Pilot_Travel_Centers_logo&quot;,
          [&quot;Dollar General&quot;],
          &quot;Dollar_General_logo&quot;,
          [&quot;Cumberland Farms Corp&quot;],
          &quot;Cumberland_Farms_logo (1)&quot;,
          [&quot;CEFCO&quot;],
          &quot;CEFCO-convenience-stores-Logo_510px&quot;,
          [&quot;BJs Wholesale Inc&quot;],
  </code></pre>
  <p><strong>The Question</strong></p>
  <p>How do I access the sprite values and not get an error?!!!
  Thanks for the help! I Wouldn't ask if I didn't need it!</p>
  <p><strong>UPDATE</strong></p>
  <p>I have figured out that to use sprite images inside of any layer, the images will automatically be available if you have them in your Mapbox studio sprite image collection. The confusion was that previously, I was not able to use them from link. However, it should work automatically.</p>
  <p>Hope it helps!</p>