<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ben Tyler</title>
    <description>The latest articles on DEV Community by Ben Tyler (@tylerben).</description>
    <link>https://dev.to/tylerben</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F556156%2F87e6c14a-ae0a-4773-a928-04fe7d4e2eca.jpg</url>
      <title>DEV Community: Ben Tyler</title>
      <link>https://dev.to/tylerben</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tylerben"/>
    <language>en</language>
    <item>
      <title>An Overview of the Mapbox Standard Style</title>
      <dc:creator>Ben Tyler</dc:creator>
      <pubDate>Thu, 24 Aug 2023 13:53:57 +0000</pubDate>
      <link>https://dev.to/tylerben/an-overview-of-the-mapbox-standard-style-5737</link>
      <guid>https://dev.to/tylerben/an-overview-of-the-mapbox-standard-style-5737</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This post is part of my &lt;a href="https://gumroad.com/l/mapbox-handbook"&gt;&lt;strong&gt;Building Interactive Maps with React&lt;/strong&gt;&lt;/a&gt; course - a course for anyone wanting to learn how to build interactive maps and integrate them into their React applications. If you enjoy this guide, then chances are you will enjoy the course too!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Mapbox recently announced the beta release of &lt;strong&gt;Mapbox GL JS v3.0.&lt;/strong&gt; Most notable with the new release is support for the new &lt;strong&gt;Mapbox Standard Style&lt;/strong&gt;. The aim of this post is to provide a summary of what the new Standard Style is and some examples of how it can be used.&lt;/p&gt;

&lt;p&gt;I setup a Code Sandbox to complement this blog post that can be explored at:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://codesandbox.io/s/mapbox-standard-style-exploration-h2c4zh"&gt;https://codesandbox.io/s/mapbox-standard-style-exploration-h2c4zh&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the Mapbox Standard Style?
&lt;/h2&gt;

&lt;p&gt;Admittedly, I found myself a bit confused by the naming and did not have much of a guess as to what “standard” style might entail. &lt;/p&gt;

&lt;p&gt;Taken from their &lt;a href="https://github.com/mapbox/mapbox-gl-js/blob/main/MIGRATION_GUIDE_v3.md"&gt;documentation&lt;/a&gt;, “The new Mapbox Standard core style enables a highly performant and elegant 3D mapping experience with powerful dynamic lighting capabilities, and an expertly crafted symbolic aesthetic.”&lt;/p&gt;

&lt;p&gt;Additionally, users of the Standard style will benefit from a basemap that is continuously updated without any additional work to have those upstreams stream through to their maps.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So basically an always up to date beautiful map that can be 3D too.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Mapbox
&lt;/h3&gt;

&lt;p&gt;To take advantage of the new Mapbox Standard style, you will need to use the latest beta release. To get started, let's install Mapbox.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
&lt;span class="c"&gt;# yarn&lt;/span&gt;
yarn add mapbox-gl@3.0.0-beta.1

&lt;span class="c"&gt;# npm&lt;/span&gt;
npm &lt;span class="nb"&gt;install &lt;/span&gt;mapbox-gl@3.0.0-beta.1 &lt;span class="nt"&gt;--save&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then make sure you include the GL JS CSS file in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; of your html document. If you are using Create React App or a similarly structured app, add it to the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; of the &lt;code&gt;index.html&lt;/code&gt; file in the &lt;code&gt;public&lt;/code&gt; directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt;
  &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"https://api.mapbox.com/mapbox-gl-js/v3.0.0-beta.1/mapbox-gl.css"&lt;/span&gt;
  &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt;
&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  How Can I Use the Standard Style in My Application?
&lt;/h2&gt;

&lt;p&gt;There are two ways to add the Standard style to your map that are detailed below.&lt;/p&gt;

&lt;h3&gt;
  
  
  Accepting Defaults
&lt;/h3&gt;

&lt;p&gt;In past versions of Mapbox GL JS, providing a style url when initializing the map has been a requirement.&lt;/p&gt;

&lt;p&gt;With the new release, the &lt;code&gt;style&lt;/code&gt; argument is now optional and will default to using the Mapbox Standard style. Initializing a map is now as simple as the below snippet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// initialize map and fall back to default style url (aka Mapbox Standard)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;mapboxgl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;container&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;map&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;center&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;87.901982&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.039403&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;pitch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;70&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// allows us to view the map in 3D&lt;/span&gt;
    &lt;span class="na"&gt;bearing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;zoom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;15.5&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Setting the Style URL
&lt;/h3&gt;

&lt;p&gt;If you prefer to be more explicit, you can still set the &lt;code&gt;style&lt;/code&gt; argument to Mapbox Standard style url. Here is an example of how to do so.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// initialize map and explicity set style url to Mapbox Standard&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;mapboxgl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;container&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;map&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mapbox://styles/mapbox/standard-beta&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;center&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;87.901982&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.039403&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;pitch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;70&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// allows us to view the map in 3D&lt;/span&gt;
    &lt;span class="na"&gt;bearing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;zoom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;15.5&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I am guessing that the style url will change once Mapbox Standard is out of public beta, but for now at least, that works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Map Lighting
&lt;/h2&gt;

&lt;p&gt;When I first read about the ability to control the maps lighting, I shrugged my shoulders and said so what. After trying out the available lighting presets though, I get it. It is wild how much you can change the look and feel of your map using the lighting presets available in Standard.&lt;/p&gt;

&lt;p&gt;There are four lighting presets available: &lt;code&gt;dawn&lt;/code&gt;, &lt;code&gt;day&lt;/code&gt;, &lt;code&gt;dusk&lt;/code&gt;, and &lt;code&gt;night&lt;/code&gt;. You can specify a lighting preset or let the Mapbox set it automatically based on a user’s time of day.&lt;/p&gt;

&lt;p&gt;Additionally, there is a new &lt;a href="https://github.com/mapbox/mapbox-gl-js/blob/main/MIGRATION_GUIDE_v3.md#lighting-api"&gt;lighting API&lt;/a&gt; that lets you customize the lighting beyond the 4 presets.&lt;/p&gt;

&lt;p&gt;Here is an example of how you can explicitly set the light preset to &lt;code&gt;dusk&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// initialize map and explicity set style url to Mapbox Standard&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;mapboxgl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;container&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;map&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;mapbox://styles/mapbox/standard-beta&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;center&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;87.901982&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.039403&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="na"&gt;pitch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;70&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;bearing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;40&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;zoom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;15.5&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;style.load&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setConfigProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;basemap&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;lightPreset&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;dusk&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Other Customization Options
&lt;/h2&gt;

&lt;p&gt;There are additionally some other config properties (mainly around labeling) of the Standard style that you can customize:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;showPlaceLabel&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;showRoadLabels&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;showPointOfInterestLabels&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;showTransitLabels&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;font&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Check out &lt;a href="https://github.com/mapbox/mapbox-gl-js/blob/main/MIGRATION_GUIDE_v3.md#explore-new-features"&gt;this section&lt;/a&gt; of the Migration Guide for more details.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Take
&lt;/h2&gt;

&lt;p&gt;Overall, I am impressed by what the Mapbox Team has built with the Mapbox Standard Style. The ease of setting up such a beautiful, performant, and dynamic map is mind blowing.&lt;/p&gt;

&lt;p&gt;Most of the maps I build rely on either satellite imagery or are set in more rural areas where buildings are not a thing. If the Mapbox team adapts this paradigm to the Outdoors style and adds better support for 3D visualization of terrain, it would be a game changer for me.&lt;/p&gt;

&lt;p&gt;Once the Standard style is out of beta though, I will likely swap it in wherever I am using their Streets style.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;If you found this post useful, please retweet, share, or &lt;a href="https://www.lostcreekdesigns.co/newsletter/"&gt;join the newsletter&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Useful Links and Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/mapbox/mapbox-gl-js/blob/main/MIGRATION_GUIDE_v3.md#migrate-to-mapbox-gl-js-v3"&gt;Mapbox GL JS v3 Migration Guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.mapbox.com/blog/standard-core-style"&gt;Mapbox Announcement Blog Post&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lostcreekdesigns.co/writing/mapbox-styles-cheatsheet"&gt;Mapbox Styles Cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>mapbox</category>
      <category>javascript</category>
      <category>react</category>
    </item>
    <item>
      <title>Time Boxed Challenges: An Easier Way to Meet Your Learning and Building Goals</title>
      <dc:creator>Ben Tyler</dc:creator>
      <pubDate>Tue, 28 Sep 2021 15:11:02 +0000</pubDate>
      <link>https://dev.to/tylerben/time-boxed-challenges-an-easier-way-to-meet-your-learning-and-building-goals-5a1p</link>
      <guid>https://dev.to/tylerben/time-boxed-challenges-an-easier-way-to-meet-your-learning-and-building-goals-5a1p</guid>
      <description>&lt;h3&gt;
  
  
  Table of Contents
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Finding a Way to Move Through the List&lt;/li&gt;
&lt;li&gt;What is a Time Boxed Personal Challenge?&lt;/li&gt;
&lt;li&gt;Why Take On a Time Boxed Personal Challenge?&lt;/li&gt;
&lt;li&gt;How to Design Your Own Personal Challenge&lt;/li&gt;
&lt;li&gt;Wrapping Up a Challenge&lt;/li&gt;
&lt;li&gt;My Current Challenge&lt;/li&gt;
&lt;li&gt;Next Steps&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a minute, think about that mental laundry list of things of things to learn or build. Maybe some free time comes up and you work on one of those items for half a day only to let it fade to the background again.Then a couple of weeks down the road you have some free time again and you pick up where you left off or even pick up a new item. No real progress gets made. &lt;/p&gt;

&lt;h2&gt;
  
  
  Finding a Way to Move Through the List
&lt;/h2&gt;

&lt;p&gt;How do you get around this though and actually consistently learn and/or build? &lt;/p&gt;

&lt;p&gt;There are a whole slew of solutions out there, but at least at the present moment, my favorite solution is the personal time boxed challenge. In other words, spending &lt;code&gt;X&lt;/code&gt; minutes per day for &lt;code&gt;X&lt;/code&gt; days working on a very specific, defined goal.&lt;/p&gt;

&lt;p&gt;This past spring, I spent 30 days doing a personal map design challenge. Each day I would take 30 minutes to focus on designing maps using Mapbox Studio. The reasoning behind it was simple - I wanted further my cartographic designs skills to the point where I could make an office worthy 18" x 24" map poster.&lt;/p&gt;

&lt;p&gt;While I am still nothing close to a cartographer, I leveled up my design and Mapbox Studio skills. It was an investment in myself that I am very happy I made and I ended up with two maps that I will be printing out as posters to hang in my office.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Time Boxed Personal Challenge?
&lt;/h2&gt;

&lt;p&gt;It can be a whole lot of things but the meat and potatoes of it comes down to spending &lt;code&gt;X&lt;/code&gt; amount of time every day for &lt;code&gt;X&lt;/code&gt; number of days. The challenge can take the shape of learning a new skill, building a side project, or a mix of the two. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;"I will spend 30 minutes a day for the next 15 days learning the foundations of JavaScript animations in React."&lt;/li&gt;
&lt;li&gt;"I will spend 30 minutes a day for the next month building out a marketing site for my side project idea."&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Take On a Time Boxed Personal Challenge?
&lt;/h2&gt;

&lt;p&gt;In addition to being fun, these types of personal challenges have a ton of benefits that include&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;providing a structured way to learn a new skill or build a new product&lt;/li&gt;
&lt;li&gt;providing a manageable framework and schedule that helps ensure consistency and increases the chances of follow through&lt;/li&gt;
&lt;li&gt;typically results in a portfolio item or product that can be leveraged in your personal or career growth&lt;/li&gt;
&lt;li&gt;if you share your progress and learnings from the challenge, can lead to new connections and getting involved in new communities&lt;/li&gt;
&lt;li&gt;can open unexpected doors and opportunities&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to Design Your Own Personal Challenge
&lt;/h2&gt;

&lt;p&gt;Setting up your own personal challenge need not be an extravagant and drawn out ordeal. Here are the general steps I like to follow.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Make a list of things that you would like to learn or build&lt;/strong&gt;. Keep the list focused on things you could complete in 10 to 20 hours and make each item as specific as possible (i.e. learn how to design a 18" x 24" map poster using Mapbox Studio).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Pick the item from the list that excites you the most&lt;/strong&gt; and select how much time you will spend working on it each day and for how many days (i.e. 30 minutes/day for 15 days). I personally like the 30 minutes/day approach for 15 to 30 days because it is enough time to make real progress on things, but not so long that it drags on and I lose interest.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Choose a time of day&lt;/strong&gt; that you will always work on your challenge. This extra step of selecting a time will help you integrate the challenge into your daily routine and will help ensure you actually take the time to work on it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Start your challenge and take a daily snapshot&lt;/strong&gt; of your progress each day. It can be incredibly rewarding and increase your motivation and confidence for future challenges if you can look back and observe your progress.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Share your daily snapshots.&lt;/strong&gt; It can be both fun and encouraging to share your daily progress with others on Twitter or any other platform of your choosing.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Wrapping Up a Challenge
&lt;/h2&gt;

&lt;p&gt;Reflecting on the work you accomplished throughout your challenge is just as important as doing the work. The process of reflection not only allows you to cement the lessons learned along the way, but can additionally be a major confidence booster and provide jet fuel for your next projects when you look at where you started and where you ended.&lt;/p&gt;

&lt;p&gt;Often times when I am considering taking on another side project, it can seem daunting and that I just do not have enough time to execute it. Doing these personal time-boxed challenges though has consistently taught me that you can get a lot done only spending 30 minutes a day for an extended period of time. Understanding that with consistent small efforts, you can build and learn some really big things, is an invaluable lesson.&lt;/p&gt;

&lt;h2&gt;
  
  
  My Current Challenge
&lt;/h2&gt;

&lt;p&gt;After wrapping up my map design challenge, I recognized this framework works really well for both learning and building things. Accordingly, it made me hungry to put together another challenge. This time around, it is taking the shape of learning how to use Figma to develop a design system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;Follow and tweet me on Twitter at &lt;a href="https://twitter.com/_btyler_"&gt;@_btyler_&lt;/a&gt; with any personal challenges you undertake. I would love to follow along and hear about what you are building and learning!&lt;/p&gt;

</description>
      <category>devjournal</category>
    </item>
    <item>
      <title>Adding a Custom Popup to a Map Layer Using React</title>
      <dc:creator>Ben Tyler</dc:creator>
      <pubDate>Mon, 26 Apr 2021 16:58:04 +0000</pubDate>
      <link>https://dev.to/tylerben/adding-a-custom-popup-to-a-map-layer-using-react-3iak</link>
      <guid>https://dev.to/tylerben/adding-a-custom-popup-to-a-map-layer-using-react-3iak</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This post is part of my &lt;a href="https://gumroad.com/l/mapbox-handbook" rel="noopener noreferrer"&gt;&lt;strong&gt;Building Interactive Maps with React&lt;/strong&gt;&lt;/a&gt; course - a course for anyone wanting to learn how to build interactive maps and integrate them into their React applications. If you enjoy this guide, then chances are you will enjoy the course too!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The previous posts in the series have covered&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how to use Mapbox Studio to manage spatial data and create custom base maps (&lt;a href="https://www.lostcreekdesigns.co/writing/tilesets-and-datasets-managing-data-in-mapbox-studio" rel="noopener noreferrer"&gt;read post&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;how to create a basic application using Mapbox and React (&lt;a href="https://www.lostcreekdesigns.co/writing/introduction-to-mapbox-and-react" rel="noopener noreferrer"&gt;read post&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These posts are helpful in understanding the basics of Mapbox Studio and the relation between Studio and Mapbox GL JS. Understanding these fundamentals is essential when you start developing much larger, data-driven mapping applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The aim of this post is to provide an introduction to adding a variety of spatial data formats to a React application using Mapbox GL JS.&lt;/strong&gt; Understanding how to add sources and layers to a map will open a lot of doors for the types of applications you can build using Mapbox GL JS.&lt;/p&gt;

&lt;p&gt;If you do not care too much about the explanations and are just looking for a snippet, check out the &lt;a href="https://codesandbox.io/s/mapbox-sources-and-layers-y0jsl?file=/src/App.js" rel="noopener noreferrer"&gt;Code Sandbox&lt;/a&gt; for this guide or scroll to the bottom of the post.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deciding Between a Custom Style and Custom Code
&lt;/h2&gt;

&lt;p&gt;I covered how to manage spatial data in Mapbox Studio using &lt;a href="https://www.lostcreekdesigns.co/writing/tilesets-and-datasets-managing-data-in-mapbox-studio" rel="noopener noreferrer"&gt;Datasets and Tilesets&lt;/a&gt; as well as &lt;a href="https://www.lostcreekdesigns.co/writing/mapbox-studio-creating-an-avalanche-atlas" rel="noopener noreferrer"&gt;how to add custom layers to a Mapbox style&lt;/a&gt; in earlier posts. If your spatial data is static and will not need to respond much to user inputs in your application, adding the spatial data to a custom Mapbox Style and then using that style in your application is probably the most ideal workflow.&lt;/p&gt;

&lt;p&gt;However, if your application and map are fairly data-driven, this guide should be very relevant to your workflow. Here are a few common examples of when it is probably easier to bring spatial data into your map and application using Mapbox GL JS versus a custom style in Mapbox Studio. There are ways to accommodate these use cases using Mapbox Studio, but I just find it easier to manage them entirely using Mapbox GL JS.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the map needs to display data that updates frequently

&lt;ul&gt;
&lt;li&gt;i.e. a delivery map that shows near real-time status and position of drivers&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;the map needs to use data from a third party API&lt;/li&gt;

&lt;li&gt;the map needs the ability to style and filter layer features based on user input&lt;/li&gt;

&lt;/ul&gt;

&lt;h2&gt;
  
  
  What We Will Build
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Finf6nsk7ut6n4f64sjr0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Finf6nsk7ut6n4f64sjr0.jpg" alt="Completed Interactive Map"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will use Mapbox GL JS and React to build an interactive map with several custom sources and layers. We will be adding sources and layers for&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;avalanche slide paths&lt;/li&gt;
&lt;li&gt;nearby weather stations&lt;/li&gt;
&lt;li&gt;bus routes&lt;/li&gt;
&lt;li&gt;3D terrain&lt;/li&gt;
&lt;li&gt;the sky&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The next sections will provide an overview of Sources and Layers followed by some concrete usage examples.&lt;/p&gt;

&lt;p&gt;If you do not care too much about the explanations and are just looking for a snippet, check out the &lt;a href="https://codesandbox.io/s/mapbox-sources-and-layers-y0jsl?file=/src/App.js" rel="noopener noreferrer"&gt;Code Sandbox&lt;/a&gt; for this guide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;I like to think of a Source as a mini datastore for my map. It tells Mapbox where to find my data as well as how to represent it. There are multiple types of Sources that you can use including: &lt;code&gt;vector&lt;/code&gt;, &lt;code&gt;raster&lt;/code&gt;, &lt;code&gt;raster-dem&lt;/code&gt;, &lt;code&gt;geojson&lt;/code&gt;, &lt;code&gt;image&lt;/code&gt;, and &lt;code&gt;video&lt;/code&gt;. This provides a lot of flexibility in terms of what kind of data can be added to a Mapbox GL JS application.&lt;/p&gt;

&lt;p&gt;Each source type has their own configuration options, but you can generally do things like set the min and max zoom thresholds for a source. The &lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/" rel="noopener noreferrer"&gt;Mapbox Style Specification&lt;/a&gt; provides a comprehensive summary of each type. For this guide though, we will be focused on the &lt;code&gt;vector&lt;/code&gt; and &lt;code&gt;geojson&lt;/code&gt; source types.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding a Vector Source
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#vector" rel="noopener noreferrer"&gt;https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#vector&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Probably the most common way of adding spatial data to a map is adding a vector tile source hosted by Mapbox. Sidenote: If you are not overly familiar with the difference between vector and raster data in the context of GIS, check out this &lt;a href="https://carto.com/blog/raster-vs-vector-whats-the-difference-which-is-best/" rel="noopener noreferrer"&gt;helpful guide&lt;/a&gt; from Carto.&lt;/p&gt;

&lt;p&gt;You can add one of Mapbox's tilesets or add your own custom tileset that is hosted on Mapbox. See this &lt;a href="https://www.lostcreekdesigns.co/writing/mapbox-studio-creating-an-avalanche-atlas" rel="noopener noreferrer"&gt;earlier post&lt;/a&gt; for instructions on how to create your own tileset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// adding a Mapbox tileset&lt;/span&gt;
&lt;span class="c1"&gt;// method expects you to provide an id for the source&lt;/span&gt;
&lt;span class="c1"&gt;// as well some configuration options&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox-streets&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vector&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox://mapbox.mapbox-streets-v8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// adding your own tileset&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vector&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox://lcdesigns.arckuvnm&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding a GeoJSON Source
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson" rel="noopener noreferrer"&gt;https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This method is great for adding in spatial data from third party APIs or pulling in data from your own APIs. You can define the GeoJSON inline, read GeoJSON directly from a local file, or hit an API endpoint that returns GeoJSON.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// inline geojson&lt;/span&gt;
&lt;span class="c1"&gt;// method expects you to provide an id for the source&lt;/span&gt;
&lt;span class="c1"&gt;// as well some configuration options&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox-streets&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Feature&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;geometry&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Polygon&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;coordinates&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;[&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;67.13734351262877&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.137451890638886&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;66.96466&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;44.8097&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;68.03252&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;44.3252&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;69.06&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.98&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.11617&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.68405&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.64573401557249&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.090083319667144&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.75102474636725&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.08003225358635&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.79761105007827&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.21973948828747&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.98176001655037&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.36789581966826&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.94416541205806&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.46633942318431&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;71.08482&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.3052400000002&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.6600225491012&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.46022288673396&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.30495378282376&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.914794623389355&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.00014034695016&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;46.69317088478567&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;69.23708614772835&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;47.44777598732787&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;68.90478084987546&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;47.184794623394396&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;68.23430497910454&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;47.35462921812177&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;67.79035274928509&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;47.066248887716995&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;67.79141211614706&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.702585354182816&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;67.13734351262877&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.137451890638886&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// adding GeoJSON read from a file&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ExampleData&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./ExampleData.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ExampleData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// adding GeoJSON from an API&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ExampleData&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./ExampleData.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://opendata.arcgis.com/datasets/4347f3565fbe4d5dbb97b016768b8907_0.geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Layers
&lt;/h2&gt;

&lt;p&gt;Layers are the visual representation of a source's data, they are what actually get rendered on the map. Once you add a source to a map, you can create any number of layers using it. For instance, if I added a source that contained city parks, I could create the following three layers from that single source.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a &lt;code&gt;fill&lt;/code&gt; layer that represents the park boundaries as shaded polygons&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;line&lt;/code&gt; layer that represents the boundaries as an outline&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;symbol&lt;/code&gt; layer that displays the park names as text labels&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mapbox supports a lot of different layer types including &lt;code&gt;background&lt;/code&gt;, &lt;code&gt;fill&lt;/code&gt;, &lt;code&gt;line&lt;/code&gt;, &lt;code&gt;symbol&lt;/code&gt;, &lt;code&gt;raster&lt;/code&gt;, &lt;code&gt;circle&lt;/code&gt;, &lt;code&gt;fill-extrusion&lt;/code&gt;, &lt;code&gt;heatmap&lt;/code&gt;, &lt;code&gt;hillshade&lt;/code&gt;, and &lt;code&gt;sky&lt;/code&gt;. It is beyond the scope of this guide to cover all of these layer types, but this guide will focus on the what you will be most likely to use, &lt;code&gt;fill&lt;/code&gt;, &lt;code&gt;line&lt;/code&gt;, &lt;code&gt;symbol&lt;/code&gt;,and &lt;code&gt;circle&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A note about layers is that they are rendered in the order they are defined. So if you want a layer to be below another one of your layers, make sure you add it first. Alternatively though, you can tell Mapbox which layer a layer should be added before/after. See &lt;a href="https://docs.mapbox.com/mapbox-gl-js/example/geojson-layer-in-stack/" rel="noopener noreferrer"&gt;this guide&lt;/a&gt; to learn how to do so.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Each layer is created in a similar fashion, but has its own unique set of &lt;code&gt;layout&lt;/code&gt; and &lt;code&gt;paint&lt;/code&gt; properties (aka how it looks) that can be configured. It is unfortunately beyond the scope of this guide to cover all of these configuration options, but the Mapbox docs do a great job. For a deeper dive into layers, check out the &lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/" rel="noopener noreferrer"&gt;Mapbox Style Specification&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding a Fill Layer
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill" rel="noopener noreferrer"&gt;https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fill layers will be your go to for visualizing polygons on a map. Think use cases like boundaries, census tracts, bodies of water, avalanche paths, building footprints, etc. The general syntax for adding a layer is more or less the same regardless of layer type. The major differences between layer types is in the layout and paint configuration options (i.e how the layer is presented and styled).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// add a fill layer to the map&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths-fill&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fill&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;source-layer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Utah_Avalanche_Paths-9s9ups&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fill-opacity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fill-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#f05c5c&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding a Circle Layer
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#circle" rel="noopener noreferrer"&gt;https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#circle&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Circle layers are useful any time you want to visualize point data. A &lt;code&gt;symbol&lt;/code&gt; layer can also be used to visualize point data but the simplicity of the &lt;code&gt;circle&lt;/code&gt; layer type can be nice, especially if you want do things like &lt;a href="https://docs.mapbox.com/help/glossary/data-driven-styling/" rel="noopener noreferrer"&gt;data-driven styling&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// add a circle layer to the map&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites-circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#ffff00&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-radius&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-stroke-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#333333&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-stroke-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding a Line Layer
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#line" rel="noopener noreferrer"&gt;https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#line&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Line layers are your best friend anytime you want to visualize a line string, think use cases like bus routes, Lyft routes, hiking tracks, rivers and streams, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// add a line layer&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-routes-line&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-routes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#15cc09&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding a Symbol Layer
&lt;/h3&gt;

&lt;p&gt;Symbol layers are the ones that took me the longest to get my head around. There are two primary use cases for &lt;code&gt;symbol&lt;/code&gt; layers: 1) if you want to visualize data using an icon and 2) if you want to label map features with some text.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can see all of the icons that are available for use as a symbol layer over at &lt;a href="https://labs.mapbox.com/maki-icons/" rel="noopener noreferrer"&gt;this page&lt;/a&gt;. Just hover over any of the icons to see the name (i.e. &lt;code&gt;airfield-15&lt;/code&gt;). You can also create and upload your own icons, but that will likely be the topic of another post.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Adding a label layer is relatively straightforward too and you can use any of the properties (fields) in your data source as labels. In the example below, there is a field called "Station Name" that I am using to label features. I am using a &lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/" rel="noopener noreferrer"&gt;Mapbox Expression&lt;/a&gt; (&lt;code&gt;["get", "Station Name"]&lt;/code&gt;) to grab the values from the &lt;code&gt;Station Name&lt;/code&gt; field.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// add a symbol layer - icon&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-stops-symbol&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;symbol&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-stops&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;icon&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bus-15&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// add a symbol layer - text label&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites-label&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;symbol&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-field&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;get&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Station Name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-size&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-offset&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#ffff00&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-halo-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#333333&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-halo-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Adding Sources and Layers to a React Map
&lt;/h2&gt;

&lt;p&gt;With all of that foundation established (a lot of it!), the following steps should hopefully make a bit more sense. In this section, we are going to use these specific methods from Mapbox GL JS to add sources and layers to an interactive map in a React application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Process Overview
&lt;/h3&gt;

&lt;p&gt;Regardless of what type of spatial data you are adding to your application, there will always be two key components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adding a source&lt;/li&gt;
&lt;li&gt;Adding a layer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Adding the source tells Mapbox that "hey, this is a data store that contains or more layers that could get added to the map". When you add a layer to a map, you then point it at the source and tell Mapbox how to represent the source on the map.&lt;/p&gt;

&lt;p&gt;If you want to follow along outside of this post, you can check the &lt;a href="https://codesandbox.io/s/mapbox-sources-and-layers-y0jsl?file=/src/App.js" rel="noopener noreferrer"&gt;Code Sandbox&lt;/a&gt; or the &lt;a href="https://github.com/tylerben/learning-sandbox/tree/master/guides/mapbox-and-react-deep-dive/sources-and-layers-guide" rel="noopener noreferrer"&gt;Github repo&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Process Implementation
&lt;/h3&gt;

&lt;p&gt;The rest of the guide is going to pick up where my earlier &lt;a href="https://www.lostcreekdesigns.co/writing/introduction-to-mapbox-and-react" rel="noopener noreferrer"&gt;Introduction to Mapbox and React post&lt;/a&gt; left off. I have put together a working snippet below filled with comments. I started out trying to explain every last bit of what was happening but think it is a lot more apparent in a lot of ways if I let the code speak for itself. I have provided links to the relevant Mapbox docs which do a much better job of explaining than I ever could. You can also refer to the primer above on sources and layers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useRef&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;mapboxgl&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox-gl&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;SnotelSites&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./lcc_snotel_sites.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="c1"&gt;// import the mapbox styles&lt;/span&gt;
&lt;span class="c1"&gt;// alternatively can use a link tag in the head of public/index.html&lt;/span&gt;
&lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/api/&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox-gl/dist/mapbox-gl.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./app.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;// Grab the access token from your Mapbox account&lt;/span&gt;
&lt;span class="c1"&gt;// I typically like to store sensitive things like this&lt;/span&gt;
&lt;span class="c1"&gt;// in a .env file&lt;/span&gt;
&lt;span class="nx"&gt;mapboxgl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;accessToken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;REACT_APP_MAPBOX_TOKEN&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mapContainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useRef&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="c1"&gt;// this is where all of our map logic is going to live&lt;/span&gt;
  &lt;span class="c1"&gt;// adding the empty dependency array ensures that the map&lt;/span&gt;
  &lt;span class="c1"&gt;// is only rendered once&lt;/span&gt;
  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// create the map and configure it&lt;/span&gt;
    &lt;span class="c1"&gt;// check out the API reference for more options&lt;/span&gt;
    &lt;span class="c1"&gt;// https://docs.mapbox.com/mapbox-gl-js/api/map/&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;mapboxgl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;container&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;mapContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox://styles/mapbox/outdoors-v11&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;center&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;111.75&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;40.581&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="na"&gt;zoom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;pitch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;bearing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="c1"&gt;// only want to work with the map after it has fully loaded&lt;/span&gt;
    &lt;span class="c1"&gt;// if you try to add sources and layers before the map has loaded&lt;/span&gt;
    &lt;span class="c1"&gt;// things will not work properly&lt;/span&gt;
    &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;load&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// add mapbox terrain dem source for 3d terrain rendering&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox-dem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;raster-dem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox://mapbox.mapbox-terrain-dem-v1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;tileSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;512&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;maxZoom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setTerrain&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox-dem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// avalanche paths source&lt;/span&gt;
      &lt;span class="c1"&gt;// example of how to add a custom tileset hosted on Mapbox&lt;/span&gt;
      &lt;span class="c1"&gt;// you can grab the url from the details page for any tileset&lt;/span&gt;
      &lt;span class="c1"&gt;// you have created in Mapbox studio&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#vector&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vector&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox://lcdesigns.arckuvnm&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// snotel sites source&lt;/span&gt;
      &lt;span class="c1"&gt;// example of using a geojson source&lt;/span&gt;
      &lt;span class="c1"&gt;// data is hosted locally as part of the application&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SnotelSites&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// bus routes source&lt;/span&gt;
      &lt;span class="c1"&gt;// another example of using a geojson source&lt;/span&gt;
      &lt;span class="c1"&gt;// this time we are hitting an ESRI API that returns&lt;/span&gt;
      &lt;span class="c1"&gt;// data in the geojson format&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-routes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://opendata.arcgis.com/datasets/4347f3565fbe4d5dbb97b016768b8907_0.geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// avalanche paths - fill layer&lt;/span&gt;
      &lt;span class="c1"&gt;// source-layer can be grabbed from the tileset details page&lt;/span&gt;
      &lt;span class="c1"&gt;// in Mapbox studio&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths-fill&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fill&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;source-layer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Utah_Avalanche_Paths-9s9ups&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fill-opacity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fill-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#f05c5c&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// snotel sites - circle layer&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#circle&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites-circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#1d1485&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-radius&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-stroke-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#ffffff&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-stroke-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// snotel sites - label layer&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#symbol&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites-label&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;symbol&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-field&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;get&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Station Name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-size&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-offset&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#1d1485&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-halo-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#ffffff&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-halo-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// bus routes - line layer&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#line&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-routes-line&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-routes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#15cc09&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// add a sky layer&lt;/span&gt;
      &lt;span class="c1"&gt;// the sky layer is a custom mapbox layer type&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#sky&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sky&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sky&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sky-type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;atmosphere&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sky-atmosphere-sun&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;90.0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sky-atmosphere-sun-intensity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="c1"&gt;// cleanup function to remove map on unmount&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;mapContainer&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;100%&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;100vh&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;This guide just scratches the surface in terms of the types of sources and layers that can be added to a map using Mapbox GL JS. I encourage you to explore the Mapbox docs and extend my examples. You could try things like...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tweaking and expanding the layer styling&lt;/li&gt;
&lt;li&gt;adding your own sources and layers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you found thus post useful, give me a follow on &lt;a href="https://twitter.com/_btyler_" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; or consider picking up a copy of the &lt;a href="https://gumroad.com/l/mapbox-handbook" rel="noopener noreferrer"&gt;Building Interactive Maps with React&lt;/a&gt; course.&lt;/p&gt;

&lt;h2&gt;
  
  
  Useful Links and Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://codesandbox.io/s/mapbox-sources-and-layers-y0jsl?file=/src/App.js" rel="noopener noreferrer"&gt;Code Sandbox&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tylerben/learning-sandbox/tree/master/guides/mapbox-and-react-deep-dive/sources-and-layers-guide" rel="noopener noreferrer"&gt;Github repo for this guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://carto.com/blog/raster-vs-vector-whats-the-difference-which-is-best/" rel="noopener noreferrer"&gt;Vector vs Raster Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/" rel="noopener noreferrer"&gt;Sources Style Spec&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#vector" rel="noopener noreferrer"&gt;Vector source&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson" rel="noopener noreferrer"&gt;GeoJSON source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/" rel="noopener noreferrer"&gt;Layers Style Spec&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill" rel="noopener noreferrer"&gt;Fill Layer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#circle" rel="noopener noreferrer"&gt;Circle Layer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#symbol" rel="noopener noreferrer"&gt;Symbol Layer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#line" rel="noopener noreferrer"&gt;Line Layer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#sky" rel="noopener noreferrer"&gt;Sky Layer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/" rel="noopener noreferrer"&gt;Mapbox Expressions&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href="https://labs.mapbox.com/maki-icons/" rel="noopener noreferrer"&gt;Mapbox Maki Icons&lt;/a&gt;&lt;/li&gt;

&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/example/geojson-layer-in-stack/" rel="noopener noreferrer"&gt;Add a new layer below labels&lt;/a&gt;&lt;/li&gt;

&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>mapbox</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Let It Simmer - Holding Off on that New Product Idea</title>
      <dc:creator>Ben Tyler</dc:creator>
      <pubDate>Thu, 01 Apr 2021 15:46:09 +0000</pubDate>
      <link>https://dev.to/tylerben/let-it-simmer-holding-off-on-that-new-product-idea-3853</link>
      <guid>https://dev.to/tylerben/let-it-simmer-holding-off-on-that-new-product-idea-3853</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I use these posts as part of my effort to sustainably build in public. My aim is to share lessons learned, prevent burnout, and connect with other motivated builders. If you are enjoying these posts, please share or give me a &lt;a href="https://twitter.com/_btyler_"&gt;follow on Twitter&lt;/a&gt;!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Saying No to Yourself
&lt;/h3&gt;

&lt;p&gt;The importance of saying "No" gets a lot of lip service, usually in the context of setting boundaries between yourself and someone else. An equally important skill is being able to say "No" to yourself, especially when you are executing on an idea and a new idea comes along. Without this, you will find yourself chasing every shiny new idea you have into the proverbial sunset of indie hacking purgatory.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Problem - Letting a New Idea Derail Your Current Project
&lt;/h3&gt;

&lt;p&gt;Something that ties a lot of us creators and indie hackers together is a seemingly bottomless well of inspiration and product ideas. Some of us execute on these ideas better than others. Some of us abandon our current idea the moment a new one comes along. Sure it is good to agile and chase down new ideas, but only up to a certain point. Follow through is important.&lt;/p&gt;

&lt;p&gt;I am speaking for myself here but I would venture to guess that some of you can relate to the following scenario. I will come up with a new product idea (usually while out on a run) and then frantically try to get the idea down on paper (aka digital paper aka Notion). The new idea then consumes most of my mental bandwidth for the rest of the day. I am gripped by thoughts like "this project really has a chance" and "I could use technology stack x, y, z to build out this set of novel features.&lt;/p&gt;

&lt;p&gt;Part of what drives this frantic shift in focus is the false sense of urgency a new idea can take on. It is easy to think things like "if I throw together a MVP for this, people will quickly see the value in this and I will be one of those success stories I see in my Twitter feed" or "if I don't execute on this quickly someone else will!" Far too often this urgency and subsequently adopted timeline are totally unnecessary. Ideas should be left to simmer on low for a while instead of throwing them into the instant pot on high.&lt;/p&gt;

&lt;p&gt;Motivation and passion are hard waves to tame though so it is easier said than done. Like a lot of self-imposed problems, I have found that strong systems and frameworks go a long way.&lt;/p&gt;

&lt;h3&gt;
  
  
  The Solution - A Project Ideas Tracker and Discipline
&lt;/h3&gt;

&lt;p&gt;Telling yourself "No" often is not any easier than telling another person no. Convincing yourself that your new idea is not the best thing you have ever dreamed up and that you need to start working on it today can additionally be a tall order. Systems work well for these kind of problems.&lt;/p&gt;

&lt;p&gt;A simple system that has worked really well for me is keeping a running Product Ideas Tracker. Like any good system, it is designed to reduce the barriers of use to maximize the chances that I will actually use it. The Product Ideas Tracker is a simple Notion page filled with general thoughts, reminders for myself, and a running list of project ideas and their current status (To Do, In Progress, Completed).&lt;/p&gt;

&lt;p&gt;I cannot explain the exact science, but the act of jotting down a new, burning idea almost immediately removes the sense of urgency of executing on the idea. There is probably something to be said for the positive re-enforcement that comes with using this system over time too. The act of cataloging the idea represents an act of nurturing the idea while at the same time setting boundaries and saying "No, not right now."&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I wanted to share the very basic Notion template I put together for the Project Ideas Tracker. You can download it for free &lt;a href="https://gum.co/BrpHd"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Closing Thoughts
&lt;/h3&gt;

&lt;p&gt;The Project Ideas Catalog is not a standalone solution in and of itself. It needs to be paired with a lot of discipline, but it at least helps to provide a framework for tracking ideas and preventing them from derailing you from your current project.&lt;/p&gt;

&lt;p&gt;I would love you to hear from you and any strategies you have found that work for preventing new ideas from derailing you. If you have comments, please reach out on &lt;a href="https://twitter.com/_btyler_"&gt;Twitter&lt;/a&gt; or share the post if you enjoyed it!&lt;/p&gt;

</description>
      <category>devjournal</category>
      <category>productivity</category>
      <category>mentalhealth</category>
      <category>career</category>
    </item>
    <item>
      <title>Narrowing Your Focus To Prevent Burnout</title>
      <dc:creator>Ben Tyler</dc:creator>
      <pubDate>Tue, 23 Mar 2021 02:55:00 +0000</pubDate>
      <link>https://dev.to/tylerben/narrow-your-focus-285h</link>
      <guid>https://dev.to/tylerben/narrow-your-focus-285h</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I use these posts as part of my effort to sustainably build in public for the long run. My aim is to share lessons learned, prevent burnout, and connect with other motivated builders. If you are enjoying these posts, please share or give me a &lt;a href="https://twitter.com/_btyler_"&gt;follow on Twitter&lt;/a&gt;!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Something I have been actively struggling with is the prioritization of ideas. My ideas list has continued to grow each week while the amount of time I have available to devote to them has held constant. Not surprisingly, this growing asymmetry has been leading to feelings of great unease.&lt;/p&gt;

&lt;h3&gt;
  
  
  Self-Driven Scope Creep
&lt;/h3&gt;

&lt;p&gt;Something I saw all the time as a consultant and in my own freelance work is scope creep - the client asking for feature x, y, and z that was not included in the original scope of work. As I add new projects to my ideas list, I tend to ride the wave of motivation and start working on it immediately, bringing my active project count up by one. In a lot of ways, my growing products and active projects list represents self-imposed scope creep. It is fairly easy to be cognizant of this when someone else is asking for additional features and products, but so much harder to recognize when you are the one guilty of it.&lt;/p&gt;

&lt;p&gt;At the start of this year, I had one project I was working on - Scoped, a budgeting and cost estimate planning tool for freelancers. Then I had an idea to start writing a Mapbox Developer's Handbook so I started working on this too. Next I added in Sonic Postcards in addition to a couple of other projects. So in three months I went from one project + a full time job to nearly five projects + a full time job. Not sustainable!&lt;/p&gt;

&lt;p&gt;If I was working with a client who was pushing for so many new features and was so blatantly guilty of scope creep, I would probably fire them as a client. So it looks like I might have to fire myself...or change.&lt;/p&gt;

&lt;h3&gt;
  
  
  Whittling Down Your Focus
&lt;/h3&gt;

&lt;p&gt;The process of telling yourself no, especially if it is related to something(s) you are deeply passionate about can be painful. I decided I needed to whittle down the total number of projects I am working on at any given time to three. This was still too much. This week I brought this number down to one.&lt;/p&gt;

&lt;p&gt;This mental framework is still sparkly fresh for me, but thus far it has helped put me ease. An added benefit has been that it has forced me to recognize if an idea is good, it will still be just as good of an idea whether I start on it today or a year from now. Someone else is likely not going to "steal" it either.&lt;/p&gt;

&lt;p&gt;Anyways, I will report back on if I have the self-control to stick to this new paradigm and how it buffs out long term.&lt;/p&gt;

&lt;p&gt;If you enjoyed this post please consider sharing it or giving me a &lt;a href="https://twitter.com/_btyler_"&gt;follow on Twitter!&lt;/a&gt;&lt;/p&gt;

</description>
      <category>career</category>
      <category>devjournal</category>
      <category>mentalhealth</category>
      <category>productivity</category>
    </item>
    <item>
      <title>What I Built Last Week - March 08, 2021</title>
      <dc:creator>Ben Tyler</dc:creator>
      <pubDate>Wed, 17 Mar 2021 01:24:22 +0000</pubDate>
      <link>https://dev.to/tylerben/what-i-built-last-week-march-08-2021-2i9i</link>
      <guid>https://dev.to/tylerben/what-i-built-last-week-march-08-2021-2i9i</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I use these posts as part of my effort to build in public. They showcase my current progress on products and audience building. They are intended to provide an imperfect snapshot of what I am working on and progress towards goals. If nothing else, they are useful to me for record keeping.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;Most of the work I put in last week in relation to indie hacking supported being able to go solidly offline for a few days. Last week was a vacation week and it was sorely needed. My wife and I took a trip down to Palm Springs to celebrate our baby moon (cringing as I am typing that phrase out). We did not get to do a proper honey moon after our wedding due to Covid and it is likely going to be a while before we get to do another trip just the two of us with a little one on the way.&lt;/p&gt;

&lt;p&gt;Writing this on Monday night listening to the new Harmony Wood's album I feel thoroughly refreshed. This weeks update has more of a philosophical bent as I did a lot of mental gymnastics in prioritizing what I want to work on in the coming weeks (it is hard!).&lt;/p&gt;

&lt;h3&gt;
  
  
  Irons in the Fire This Week
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Developing new "Postcards" music newsletter&lt;/li&gt;
&lt;li&gt;Mapbox and React Deep Dives series&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gumroad.com/btyler"&gt;Mapbox Developers Handbook&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Strategy&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Metrics
&lt;/h3&gt;

&lt;p&gt;Making just about everything transparent and accessible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can check out the &lt;a href="https://datastudio.google.com/reporting/7278763f-4383-4dee-99f4-f2951816f6a7"&gt;Growth Dashboard&lt;/a&gt; I mentioned below&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are the things I worked on during the last week.&lt;/p&gt;

&lt;h2&gt;
  
  
  Strategy
&lt;/h2&gt;

&lt;p&gt;Prioritizing what to work has been a challenge over the past month. The list of side projects that I would like to focus on continue to grows while the amount of time I have available remains the same (hardly a unique problem). As such, a lot of my energy as of late has been focused on strategy and making clear plans of actions and timelines for the various irons I have in the fire.&lt;/p&gt;

&lt;p&gt;This led me to reflecting a lot on how I managed time in the past and eventually led me to reflecting on my time as a high school and collegiate athlete. I realized that it was a time that is not all that dissimilar to where I am at now. Going to class is analogous to my day job and cross country/track are analogous to my side projects. I had goals for both and had to learn how to set and them for each aspect of my life.&lt;/p&gt;

&lt;p&gt;A large part of setting goals for cross country and track involved setting short, medium, long, and extra long term goals. My freshmen year I wanted to be an all american by the time I graduated (unfortunately didn't happen). It was a massive goal and something that needed to get broken down into smaller goals to allow me to have any shot at accomplishing it. So I set long term goals like qualify for nationals this year, medium term goals like place top 10 at the conference meet, and short term goals like place top 5 in the race this coming weekend.&lt;/p&gt;

&lt;p&gt;There is so much in this approach and breaking work down into the concept of seasons like you have in athletics that extends itself to building products. A big part in achieving my athletic goals was developing a training plan(s) for each season. The training plan blended a variety of workout types (regular aerobic runs, speed work, tempo runs, race simulations, and long runs) to get me in the shape I needed to be in to have a realistic shot at accomplishing my goals. They work really well.&lt;/p&gt;

&lt;p&gt;I'm the middle of this trying this out, but I think the idea of developing training plans for indie hacking could work really well. More on this in the coming weeks though...&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If you enjoyed this post please consider sharing it or giving me a &lt;a href="https://twitter.com/_btyler_"&gt;follow on Twitter&lt;/a&gt;!&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>devjournal</category>
    </item>
    <item>
      <title>How to Style Map Layers in Mapbox GL JS</title>
      <dc:creator>Ben Tyler</dc:creator>
      <pubDate>Wed, 03 Mar 2021 15:31:58 +0000</pubDate>
      <link>https://dev.to/tylerben/how-to-style-map-layers-in-mapbox-gl-js-4l7c</link>
      <guid>https://dev.to/tylerben/how-to-style-map-layers-in-mapbox-gl-js-4l7c</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This post is part of my &lt;a href="https://gumroad.com/l/mapbox-handbook"&gt;&lt;strong&gt;Building Interactive Maps with React&lt;/strong&gt;&lt;/a&gt; course - a course for anyone wanting to learn how to build interactive maps and integrate them into their React applications. If you enjoy this guide, then chances are you will enjoy the course too!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The last few posts in this series have focused on &lt;a href="https://www.lostcreekdesigns.co/writing/tilesets-and-datasets-managing-data-in-mapbox-studio"&gt;integrating spatial data into Mapbox Studio&lt;/a&gt; and Mapbox GL JS applications. The logical next step is to focus on the presentation of spatial data. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The aim of this guide is to provide an overview and list of resources detailing how map layers can be styled using Mapbox GL JS.&lt;/strong&gt; This guide will more closely resemble a collection of resources than a technical guide. If I opted to cover every way a map layer can be styled, I would be writing this post for the rest of the year.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started
&lt;/h2&gt;

&lt;p&gt;This post picks up where &lt;a href="https://www.lostcreekdesigns.co/writing/a-complete-guide-to-sources-and-layers-in-react-and-mapbox-gl-js"&gt;A Complete Guide to Sources and Layers in React and Mapbox GL JS&lt;/a&gt; leaves off. To get the most out of this guide, you should be familiar with how to add sources and layers to a map using Mapbox GL JS. There are a couple of different ways to style map layers, but all rely on the same underlying style specification of &lt;code&gt;layout&lt;/code&gt; and &lt;code&gt;paint&lt;/code&gt; properties. We will begin here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layout and Paint Properties
&lt;/h2&gt;

&lt;p&gt;The specification for a Mapbox layer has two style-related properties, &lt;code&gt;layout&lt;/code&gt; and &lt;code&gt;paint&lt;/code&gt;, that work in tandem to control how a map layer is &lt;strong&gt;rendered&lt;/strong&gt; and &lt;strong&gt;styled&lt;/strong&gt;. It can be a bit tricky to remember the difference between the two, but it is a safe bet to say (unless you are working with the &lt;code&gt;symbol&lt;/code&gt; layer type) that you will be focused on the &lt;code&gt;paint&lt;/code&gt; property the majority of the time. With the exception of the &lt;code&gt;symbol&lt;/code&gt; and &lt;code&gt;line&lt;/code&gt; layer, all of the layer types only have one valid &lt;code&gt;layout&lt;/code&gt; property which is &lt;code&gt;visibility&lt;/code&gt;.  &lt;/p&gt;

&lt;p&gt;Mapbox provides great documentation on the &lt;code&gt;layout&lt;/code&gt; and &lt;code&gt;paint&lt;/code&gt; properties.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill"&gt;All of the layout and paint properties available by layer type&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/help/glossary/layout-paint-property/"&gt;The difference between the layout and paint properties&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is an example snippet showing both the &lt;code&gt;layout&lt;/code&gt; and &lt;code&gt;paint&lt;/code&gt; properties in action. This results in a visible layer with rounded line ends with a blue stroke and 2px stroke width.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rivers-layer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rivers&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-cap&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;round&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;visibility&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;visible&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#6382f2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Different Ways To Style a Layer
&lt;/h2&gt;

&lt;p&gt;A powerful feature of Mapbox GL JS is that you can style map layers when they are added to the map or after. This provides a lot of flexibility in terms of allowing your map styles to adapt to changes in your application. You can find a full list of all the different styling options that available to each layer type &lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Styling a layer when it is added to the map
&lt;/h3&gt;

&lt;p&gt;Using this approach, we apply the map styles when it is added to the map. Unless the map layer styling needs to respond to changes in your application or user input, this is the recommended approach. As you can see, most the time there isn't even a need to include the &lt;code&gt;layout&lt;/code&gt; property when styling a layer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-stops-circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-stops&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#1d1485&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-radius&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-stroke-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#ffffff&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-stroke-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Styling a layer after it is added to the map
&lt;/h3&gt;

&lt;p&gt;There are some instances where you would want to delay styling the map layer or to apply new styling based on some change in your application. Some valid use cases include toggling layer visibility, changing the color of a layer based on user input, styling a layer based on data, etc. Luckily, the &lt;code&gt;setPaintProperty()&lt;/code&gt; and &lt;code&gt;setLayoutProperty()&lt;/code&gt; methods in Mapbox GL JS make this relatively painless.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;More information&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/api/map/#map#setpaintproperty"&gt;setPaintProperty()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/api/map/#map#setlayoutproperty"&gt;setLayoutProperty()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.mapbox.com/mapbox-gl-js/example/color-switcher/"&gt;example of &lt;code&gt;setPaintProperty()&lt;/code&gt; in action&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// add the layer to the map but have it be hidden initially&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-stops-circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-stops&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;visibility&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;none&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#1d1485&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-radius&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-stroke-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#ffffff&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-stroke-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// layer visibility toggle handler that could be attached&lt;/span&gt;
&lt;span class="c1"&gt;// elsewhere in your application&lt;/span&gt;
&lt;span class="c1"&gt;// something like toggleLayerVisibility('bus-stops-circle')&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;toggleLayerVisibility&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;layerId&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;visibility&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getLayoutProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;layerId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;visibility&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;visibility&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;visible&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setLayoutProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;layerId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;visibility&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;none&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setLayoutProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;layerId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;visibility&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;visible&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// example of how you set invidual paint properties&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;changeCircleColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;layerId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setPaintProperty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;layerId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;circle-color&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;color&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Styling a Layer Conditionally
&lt;/h3&gt;

&lt;p&gt;One of the most powerful aspects of styling is the ability to apply styles based on different conditions. Mapbox GL JS allows you to style layers based on&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;characteristics of the layer data (i.e. color all counties with a population of greater than some number blue)&lt;/li&gt;
&lt;li&gt;the zoom range (i.e. when really zoomed in make the rivers map layer thinner but when really zoomed out make it thicker)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Implementing either approach relies on a core concept in Mapbox GL JS which is &lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/"&gt;expressions&lt;/a&gt;. I honestly have to return to the docs every time I work with them. They are mighty powerful but also mighty confusing. &lt;/p&gt;

&lt;p&gt;Tip! You can use Mapbox Studio to quickly prototype layer styling. This is especially valuable for data driven styling. Select the layer and paint property you would like to style (i.e. &lt;code&gt;fill&lt;/code&gt;) and then select to style it across a zoom range, data range, or across data conditions in the UI. After you have things looking like you want, select the &lt;code&gt;&amp;lt;/&amp;gt;&lt;/code&gt; icon in the bottom right corner of the drawer. This will expose the Mapbox expression needed for the data/zoom driven styling. You can then easily copy and paste it into your code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;More information&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/example/data-driven-circle-colors/"&gt;Style circles with a data-driven property&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/"&gt;Mapbox GL JS Expressions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/help/tutorials/mapbox-gl-js-expressions/"&gt;Get started with Mapbox GL JS expressions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here is an example of using expressions for data-driven and zoom-driven styling.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rivers-line&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;rivers&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#6382f2&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="c1"&gt;// make streams larger as the user zooms from z0 to z22&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;base&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// default value&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;stops&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
                &lt;span class="c1"&gt;// first # is the zoom level, second # is the style val&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;22&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="c1"&gt;// color lines based on water quality data&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;match&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;get&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;quality&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;poor&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#f84c35&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;average&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#f84c35&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;good&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#f84c35&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#dddddd&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="c1"&gt;// fallback value&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;I encourage you to go deep on the styling topic. The art of styling a map is equally as important as bringing it to life with interactivity and should not be overlooked. My recommendation is to spend some exploring styling using the Mapbox Studio UI. It is a great place to come up to speed on all of the different ways you can style different layer types. It is is easy to iterate and then take what you learn and apply it in the context of Mapbox GL JS.&lt;/p&gt;

&lt;p&gt;If you found this post useful, please retweet, share, or pick up a copy of &lt;a href="https://gumroad.com/l/mapbox-handbook"&gt;The Mapbox Developer's Handbook&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Useful Links and Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill"&gt;All of the layout and paint properties available by layer type&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/help/glossary/layout-paint-property/"&gt;The difference between the layout and paint properties&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/api/map/#map#setpaintproperty"&gt;setPaintProperty()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/api/map/#map#setlayoutproperty"&gt;setLayoutProperty()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/example/color-switcher/"&gt;example of &lt;code&gt;setPaintProperty()&lt;/code&gt; in action&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/example/data-driven-circle-colors/"&gt;Style circles with a data-driven property&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/"&gt;Mapbox GL JS Expressions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/help/tutorials/mapbox-gl-js-expressions/"&gt;Get started with Mapbox GL JS expressions&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>javascript</category>
      <category>react</category>
      <category>mapbox</category>
    </item>
    <item>
      <title>What I Built Last Week - Feb 22, 2021</title>
      <dc:creator>Ben Tyler</dc:creator>
      <pubDate>Tue, 02 Mar 2021 16:10:49 +0000</pubDate>
      <link>https://dev.to/tylerben/what-i-built-last-week-feb-22-2021-33f4</link>
      <guid>https://dev.to/tylerben/what-i-built-last-week-feb-22-2021-33f4</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I use these posts as part of my effort to build in public. They showcase my current progress on products and audience building. They are intended to provide an imperfect snapshot of what I am working on and progress towards goals. If nothing else, they are useful to me for record keeping.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;Last week was a relatively mellow week in terms of productivity on the side projects. I made the conscious choice to not work over the weekend too so I could recharge a bit. I am really glad I opted for the time off.&lt;/p&gt;

&lt;h3&gt;
  
  
  Irons in the Fire This Week
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Developing new "Postcards" music newsletter&lt;/li&gt;
&lt;li&gt;Mapbox and React Deep Dives series&lt;/li&gt;
&lt;li&gt;Mapbox Developers Handbook&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Metrics
&lt;/h3&gt;

&lt;p&gt;Making just about everything transparent and accessible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can check out the &lt;a href="https://datastudio.google.com/reporting/7278763f-4383-4dee-99f4-f2951816f6a7"&gt;Growth Dashboard&lt;/a&gt; I mentioned below&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are the things I worked on during the last week.&lt;/p&gt;

&lt;h2&gt;
  
  
  Personal Site Improvements
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The What
&lt;/h3&gt;

&lt;p&gt;I continued making some small stylistic tweaks to the site (mostly typography related). The main improvements I made centered around internal tooling. I expanded my existing utility scripts for generating a new blog post to support multiple different templates now that I have a few recurring weekly posts (i.e. What I Built Last Week, Songs of the Week, Mapbox and React Deep Dives).&lt;/p&gt;

&lt;h3&gt;
  
  
  The Why
&lt;/h3&gt;

&lt;p&gt;I have been trying to automate as many things as I can. I have fairly limited free time (1 to 2 hours a day) to devote to side projects, so the less time I have to spend on repeatable, non-value add tasks the better. Expanding my blog post generation utility script to support different templates has already saved me a good amount of time. I will probably write a post on how I did this, but it loosely follows &lt;a href="https://www.lostcreekdesigns.co/writing/auto-generating-a-react-component-with-intelligent-boilerplate"&gt;the process&lt;/a&gt; I used to develop a utility script for auto-generating React Components.&lt;/p&gt;

&lt;h2&gt;
  
  
  Writing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The What
&lt;/h3&gt;

&lt;p&gt;I put out three blog posts last week:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.lostcreekdesigns.co/writing/a-complete-guide-to-sources-and-layers-in-react-and-mapbox-gl-js"&gt;A Complete Guide to Sources and Layers in React and Mapbox GL JS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lostcreekdesigns.co/writing/what-i-built-last-week-february-15-2021"&gt;What I Built Last Week - February 15, 2021&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lostcreekdesigns.co/writing/songs-of-the-week-february-22-2021"&gt;Songs of the Week - February 22, 2021&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The guide to sources and layers was a beast and a wake up call on just how involved some of these remaining Mapbox and React Deep Dive guides are going to be. Initially I had hoped to put two to three of these posts out a week, but realistically it will probably be limited to one.&lt;/p&gt;

&lt;p&gt;I have been having fun with the &lt;strong&gt;What I Built This Week&lt;/strong&gt; and &lt;strong&gt;Songs of the Week&lt;/strong&gt; series though. There is something freeing about the formats as I do not have to worry about suggesting a "correct" solution to a problem, I just get to write.&lt;/p&gt;

&lt;p&gt;That's it for the updates this week!&lt;/p&gt;

</description>
      <category>devjournal</category>
    </item>
    <item>
      <title>What I Built Last Week - February 15, 2021</title>
      <dc:creator>Ben Tyler</dc:creator>
      <pubDate>Wed, 24 Feb 2021 16:27:37 +0000</pubDate>
      <link>https://dev.to/tylerben/what-i-built-last-week-february-15-2021-2h03</link>
      <guid>https://dev.to/tylerben/what-i-built-last-week-february-15-2021-2h03</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;I use these posts are part of my effort to build in public. They are intended to provide an imperfect snapshot of what I am working on and progress towards goals. If nothing else, they are useful to me as record keeping. If you want to get these updates in your inbox, &lt;a href="https://www.lostcreekdesigns.co/newsletter/"&gt;join the newsletter&lt;/a&gt;!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;I spent the majority of last week focused on on my &lt;a href="https://www.lostcreekdesigns.co/writing/a-complete-guide-to-sources-and-layers-in-react-and-mapbox-gl-js"&gt;Mapbox and React Deep Dives series&lt;/a&gt; and switching my &lt;a href="https://www.lostcreekdesigns.co/"&gt;personal site&lt;/a&gt; over from MailChimp to ConvertKit. Initially the idea of a newsletter or mailing list made me cringe (it feels too salesy). The process of building in public has made me re-evaluate my categorically bad assessment of things like SEO, newsletters, Twitter, and marketing though. It has been refreshing to have this previously held ideas challenged.&lt;/p&gt;

&lt;h3&gt;
  
  
  Irons in the Fire
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.lostcreekdesigns.co/writing/introducing-mapbox-and-react-deep-dives"&gt;Mapbox &amp;amp; React Deep Dives series&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://gumroad.com/l/scoped"&gt;Scoped - A Scoping &amp;amp; Budget Planning Tool for Freelancers&lt;/a&gt; (free/pay what you want)&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lostcreekdesigns.co/newsletter/"&gt;Newsletter&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lostcreekdesigns.co/"&gt;Personal site redesign&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Metrics
&lt;/h3&gt;

&lt;p&gt;Making just about everything transparent and accessible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You can check out the &lt;a href="https://datastudio.google.com/reporting/7278763f-4383-4dee-99f4-f2951816f6a7"&gt;Growth Dashboard&lt;/a&gt; I mentioned below&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are the things I worked on during the last week.&lt;/p&gt;

&lt;h2&gt;
  
  
  Growth Dashboard
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QN9lwVEu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/no578wxj43ghwcfulq3w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QN9lwVEu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/no578wxj43ghwcfulq3w.png" alt="Growth dashboard" width="800" height="602"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The What
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;growth analytics dashboard built on top of Google Sheets and Google Data Studio. Access it &lt;a href="https://datastudio.google.com/reporting/7278763f-4383-4dee-99f4-f2951816f6a7"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;bare bones at this point. Opting for simplicity as it increases the likelihood of me updating the metrics.&lt;/li&gt;
&lt;li&gt;eventually would like to bring greater automation to the process&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Why
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;to understand how various aspects of efforts are/are not working&lt;/li&gt;
&lt;li&gt;easy way to visualize targets and progress towards them&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Newsletter &amp;amp; Mailing List
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--k2Z9J7hM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5l734s8kqefcdwjzu0qj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--k2Z9J7hM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5l734s8kqefcdwjzu0qj.png" alt="Redesigned home page with newsletter signup" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The What
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Switched over from MailChimp to ConvertKit&lt;/li&gt;
&lt;li&gt;Redesigned my personal site home page to more prominently feature newsletter&lt;/li&gt;
&lt;li&gt;Started strategizing more around newsletter/mailing list (despite my initial opposition)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Why
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;necessary to promote my products and hopefully help people.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Personal Site Improvements
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--omckfdkF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8kci4hah9v29pvcrdhwn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--omckfdkF--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8kci4hah9v29pvcrdhwn.png" alt="New writing layout with newsletter signup" width="800" height="414"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  The What
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Redesigned my personal site home page to more prominently feature newsletter&lt;/li&gt;
&lt;li&gt;Added a newsletter sign up page&lt;/li&gt;
&lt;li&gt;Improved layout and other style issues throughout the site&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The Why
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Wanted to more prominently feature the newsletter and convert that into sign ups&lt;/li&gt;
&lt;li&gt;Fix some styling issues that had been bothering me for a while&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Writing
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The What
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Published two blog posts

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.lostcreekdesigns.co/writing/tilesets-and-datasets-managing-data-in-mapbox-studio"&gt;Tilesets &amp;amp; Datasets: Managing Data in Mapbox Studio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.lostcreekdesigns.co/writing/songs-of-the-week-february-14-2021"&gt;Songs of the Week - February 14, 2021&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you found this post useful, please retweet, share, or &lt;a href="https://www.lostcreekdesigns.co/newsletter/"&gt;join the newsletter&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>devjournal</category>
      <category>productivity</category>
    </item>
    <item>
      <title>A Complete Guide to Sources and Layers in React and Mapbox GL JS</title>
      <dc:creator>Ben Tyler</dc:creator>
      <pubDate>Tue, 23 Feb 2021 15:23:30 +0000</pubDate>
      <link>https://dev.to/tylerben/a-complete-guide-to-sources-and-layers-in-react-and-mapbox-gl-js-4jib</link>
      <guid>https://dev.to/tylerben/a-complete-guide-to-sources-and-layers-in-react-and-mapbox-gl-js-4jib</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl9ywqx7o8a4508uae6tr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl9ywqx7o8a4508uae6tr.png" alt="Sources and Layers Infographic" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This post is part of my &lt;a href="https://gumroad.com/l/mapbox-handbook"&gt;&lt;strong&gt;Building Interactive Maps with React&lt;/strong&gt;&lt;/a&gt; course - a course for anyone wanting to learn how to build interactive maps and integrate them into their React applications. If you enjoy this guide, then chances are you will enjoy the course too!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The previous posts in the series have covered&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how to use Mapbox Studio to manage spatial data and create custom base maps (&lt;a href="https://www.lostcreekdesigns.co/writing/tilesets-and-datasets-managing-data-in-mapbox-studio"&gt;read post&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;how to create a basic application using Mapbox and React (&lt;a href="https://www.lostcreekdesigns.co/writing/introduction-to-mapbox-and-react"&gt;read post&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These posts are helpful in understanding the basics of Mapbox Studio and the relation between Studio and Mapbox GL JS. Understanding these fundamentals is essential when you start developing much larger, data-driven mapping applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The aim of this post is to provide an introduction to adding a variety of spatial data formats to a React application using Mapbox GL JS.&lt;/strong&gt; Understanding how to add sources and layers to a map will open a lot of doors for the types of applications you can build using Mapbox GL JS.&lt;/p&gt;

&lt;p&gt;If you do not care too much about the explanations and are just looking for a snippet, check out the &lt;a href="https://codesandbox.io/s/mapbox-sources-and-layers-y0jsl?file=/src/App.js"&gt;Code Sandbox&lt;/a&gt; for this guide or scroll to the bottom of the post.&lt;/p&gt;

&lt;h2&gt;
  
  
  Deciding Between a Custom Style and Custom Code
&lt;/h2&gt;

&lt;p&gt;I covered how to manage spatial data in Mapbox Studio using &lt;a href="https://www.lostcreekdesigns.co/writing/tilesets-and-datasets-managing-data-in-mapbox-studio"&gt;Datasets and Tilesets&lt;/a&gt; as well as &lt;a href="https://www.lostcreekdesigns.co/writing/mapbox-studio-creating-an-avalanche-atlas"&gt;how to add custom layers to a Mapbox style&lt;/a&gt; in earlier posts. If your spatial data is static and will not need to respond much to user inputs in your application, adding the spatial data to a custom Mapbox Style and then using that style in your application is probably the most ideal workflow.&lt;/p&gt;

&lt;p&gt;However, if your application and map are fairly data-driven, this guide should be very relevant to your workflow. Here are a few common examples of when it is probably easier to bring spatial data into your map and application using Mapbox GL JS versus a custom style in Mapbox Studio. There are ways to accommodate these use cases using Mapbox Studio, but I just find it easier to manage them entirely using Mapbox GL JS.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the map needs to display data that updates frequently

&lt;ul&gt;
&lt;li&gt;i.e. a delivery map that shows near real-time status and position of drivers&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;the map needs to use data from a third party API&lt;/li&gt;
&lt;li&gt;the map needs the ability to style and filter layer features based on user input&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What We Will Build
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Finf6nsk7ut6n4f64sjr0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Finf6nsk7ut6n4f64sjr0.jpg" alt="Completed interactive map" width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We will use Mapbox GL JS and React to build an interactive map with several custom sources and layers. We will be adding sources and layers for&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;avalanche slide paths&lt;/li&gt;
&lt;li&gt;nearby weather stations&lt;/li&gt;
&lt;li&gt;bus routes&lt;/li&gt;
&lt;li&gt;3D terrain&lt;/li&gt;
&lt;li&gt;the sky&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The next sections will provide an overview of Sources and Layers followed by some concrete usage examples.&lt;/p&gt;

&lt;p&gt;If you do not care too much about the explanations and are just looking for a snippet, check out the &lt;a href="https://codesandbox.io/s/mapbox-sources-and-layers-y0jsl?file=/src/App.js"&gt;Code Sandbox&lt;/a&gt; for this guide.&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;I like to think of a Source as a mini datastore for my map. It tells Mapbox where to find my data as well as how to represent it. There are multiple types of Sources that you can use including: &lt;code&gt;vector&lt;/code&gt;, &lt;code&gt;raster&lt;/code&gt;, &lt;code&gt;raster-dem&lt;/code&gt;, &lt;code&gt;geojson&lt;/code&gt;, &lt;code&gt;image&lt;/code&gt;, and &lt;code&gt;video&lt;/code&gt;. This provides a lot of flexibility in terms of what kind of data can be added to a Mapbox GL JS application.&lt;/p&gt;

&lt;p&gt;Each source type has their own configuration options, but you can generally do things like set the min and max zoom thresholds for a source. The &lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/"&gt;Mapbox Style Specification&lt;/a&gt; provides a comprehensive summary of each type. For this guide though, we will be focused on the &lt;code&gt;vector&lt;/code&gt; and &lt;code&gt;geojson&lt;/code&gt; source types.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding a Vector Source
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#vector"&gt;https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#vector&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Probably the most common way of adding spatial data to a map is adding a vector tile source hosted by Mapbox. Sidenote: If you are not overly familiar with the difference between vector and raster data in the context of GIS, check out this &lt;a href="https://carto.com/blog/raster-vs-vector-whats-the-difference-which-is-best/"&gt;helpful guide&lt;/a&gt; from Carto.&lt;/p&gt;

&lt;p&gt;You can add one of Mapbox's tilesets or add your own custom tileset that is hosted on Mapbox. See this &lt;a href="https://www.lostcreekdesigns.co/writing/mapbox-studio-creating-an-avalanche-atlas"&gt;earlier post&lt;/a&gt; for instructions on how to create your own tileset.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// adding a Mapbox tileset&lt;/span&gt;
&lt;span class="c1"&gt;// method expects you to provide an id for the source&lt;/span&gt;
&lt;span class="c1"&gt;// as well some configuration options&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox-streets&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vector&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox://mapbox.mapbox-streets-v8&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// adding your own tileset&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vector&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox://lcdesigns.arckuvnm&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding a GeoJSON Source
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson"&gt;https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This method is great for adding in spatial data from third party APIs or pulling in data from your own APIs. You can define the GeoJSON inline, read GeoJSON directly from a local file, or hit an API endpoint that returns GeoJSON.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// inline geojson&lt;/span&gt;
&lt;span class="c1"&gt;// method expects you to provide an id for the source&lt;/span&gt;
&lt;span class="c1"&gt;// as well some configuration options&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox-streets&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Feature&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;geometry&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Polygon&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;coordinates&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
            &lt;span class="p"&gt;[&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;67.13734351262877&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.137451890638886&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;66.96466&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;44.8097&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;68.03252&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;44.3252&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;69.06&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.98&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.11617&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.68405&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.64573401557249&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.090083319667144&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.75102474636725&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.08003225358635&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.79761105007827&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.21973948828747&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.98176001655037&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.36789581966826&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.94416541205806&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;43.46633942318431&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;71.08482&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.3052400000002&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.6600225491012&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.46022288673396&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.30495378282376&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.914794623389355&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;70.00014034695016&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;46.69317088478567&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;69.23708614772835&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;47.44777598732787&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;68.90478084987546&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;47.184794623394396&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;68.23430497910454&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;47.35462921812177&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;67.79035274928509&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;47.066248887716995&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;67.79141211614706&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.702585354182816&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
                &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;67.13734351262877&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;45.137451890638886&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
            &lt;span class="p"&gt;]&lt;/span&gt;
        &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// adding GeoJSON read from a file&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ExampleData&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./ExampleData.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ExampleData&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// adding GeoJSON from an API&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;ExampleData&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./ExampleData.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://opendata.arcgis.com/datasets/4347f3565fbe4d5dbb97b016768b8907_0.geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Layers
&lt;/h2&gt;

&lt;p&gt;Layers are the visual representation of a source's data, they are what actually get rendered on the map. Once you add a source to a map, you can create any number of layers using it. For instance, if I added a source that contained city parks, I could create the following three layers from that single source.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a &lt;code&gt;fill&lt;/code&gt; layer that represents the park boundaries as shaded polygons&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;line&lt;/code&gt; layer that represents the boundaries as an outline&lt;/li&gt;
&lt;li&gt;a &lt;code&gt;symbol&lt;/code&gt; layer that displays the park names as text labels&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Mapbox supports a lot of different layer types including &lt;code&gt;background&lt;/code&gt;, &lt;code&gt;fill&lt;/code&gt;, &lt;code&gt;line&lt;/code&gt;, &lt;code&gt;symbol&lt;/code&gt;, &lt;code&gt;raster&lt;/code&gt;, &lt;code&gt;circle&lt;/code&gt;, &lt;code&gt;fill-extrusion&lt;/code&gt;, &lt;code&gt;heatmap&lt;/code&gt;, &lt;code&gt;hillshade&lt;/code&gt;, and &lt;code&gt;sky&lt;/code&gt;. It is beyond the scope of this guide to cover all of these layer types, but this guide will focus on the what you will be most likely to use, &lt;code&gt;fill&lt;/code&gt;, &lt;code&gt;line&lt;/code&gt;, &lt;code&gt;symbol&lt;/code&gt;,and &lt;code&gt;circle&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A note about layers is that they are rendered in the order they are defined. So if you want a layer to be below another one of your layers, make sure you add it first. Alternatively though, you can tell Mapbox which layer a layer should be added before/after. See &lt;a href="https://docs.mapbox.com/mapbox-gl-js/example/geojson-layer-in-stack/"&gt;this guide&lt;/a&gt; to learn how to do so.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Each layer is created in a similar fashion, but has its own unique set of &lt;code&gt;layout&lt;/code&gt; and &lt;code&gt;paint&lt;/code&gt; properties (aka how it looks) that can be configured. It is unfortunately beyond the scope of this guide to cover all of these configuration options, but the Mapbox docs do a great job. For a deeper dive into layers, check out the &lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/"&gt;Mapbox Style Specification&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding a Fill Layer
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill"&gt;https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Fill layers will be your go to for visualizing polygons on a map. Think use cases like boundaries, census tracts, bodies of water, avalanche paths, building footprints, etc. The general syntax for adding a layer is more or less the same regardless of layer type. The major differences between layer types is in the layout and paint configuration options (i.e how the layer is presented and styled).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// add a fill layer to the map&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths-fill&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fill&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;source-layer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Utah_Avalanche_Paths-9s9ups&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fill-opacity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fill-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#f05c5c&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding a Circle Layer
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#circle"&gt;https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#circle&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Circle layers are useful any time you want to visualize point data. A &lt;code&gt;symbol&lt;/code&gt; layer can also be used to visualize point data but the simplicity of the &lt;code&gt;circle&lt;/code&gt; layer type can be nice, especially if you want do things like &lt;a href="https://docs.mapbox.com/help/glossary/data-driven-styling/"&gt;data-driven styling&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// add a circle layer to the map&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites-circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#ffff00&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-radius&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-stroke-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#333333&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-stroke-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding a Line Layer
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#line"&gt;https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#line&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Line layers are your best friend anytime you want to visualize a line string, think use cases like bus routes, Lyft routes, hiking tracks, rivers and streams, etc.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// add a line layer&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-routes-line&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-routes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#15cc09&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding a Symbol Layer
&lt;/h3&gt;

&lt;p&gt;Symbol layers are the ones that took me the longest to get my head around. There are two primary use cases for &lt;code&gt;symbol&lt;/code&gt; layers: 1) if you want to visualize data using an icon and 2) if you want to label map features with some text.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You can see all of the icons that are available for use as a symbol layer over at &lt;a href="https://labs.mapbox.com/maki-icons/"&gt;this page&lt;/a&gt;. Just hover over any of the icons to see the name (i.e. &lt;code&gt;airfield-15&lt;/code&gt;). You can also create and upload your own icons, but that will likely be the topic of another post.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Adding a label layer is relatively straightforward too and you can use any of the properties (fields) in your data source as labels. In the example below, there is a field called "Station Name" that I am using to label features. I am using a &lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/"&gt;Mapbox Expression&lt;/a&gt; (&lt;code&gt;["get", "Station Name"]&lt;/code&gt;) to grab the values from the &lt;code&gt;Station Name&lt;/code&gt; field.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// add a symbol layer - icon&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-stops-symbol&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;symbol&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-stops&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;icon&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bus-15&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
     &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="c1"&gt;// add a symbol layer - text label&lt;/span&gt;
&lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites-label&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;symbol&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-field&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;get&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Station Name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-size&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-offset&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#ffff00&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-halo-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#333333&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-halo-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Adding Sources and Layers to a React Map
&lt;/h2&gt;

&lt;p&gt;With all of that foundation established (a lot of it!), the following steps should hopefully make a bit more sense. In this section, we are going to use these specific methods from Mapbox GL JS to add sources and layers to an interactive map in a React application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Process Overview
&lt;/h3&gt;

&lt;p&gt;Regardless of what type of spatial data you are adding to your application, there will always be two key components:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Adding a source&lt;/li&gt;
&lt;li&gt;Adding a layer&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Adding the source tells Mapbox that "hey, this is a data store that contains or more layers that could get added to the map". When you add a layer to a map, you then point it at the source and tell Mapbox how to represent the source on the map.&lt;/p&gt;

&lt;p&gt;If you want to follow along outside of this post, you can check the &lt;a href="https://codesandbox.io/s/mapbox-sources-and-layers-y0jsl?file=/src/App.js"&gt;Code Sandbox&lt;/a&gt; or the &lt;a href="https://github.com/tylerben/learning-sandbox/tree/master/guides/mapbox-and-react-deep-dive/sources-and-layers-guide"&gt;Github repo&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Process Implementation
&lt;/h3&gt;

&lt;p&gt;The rest of the guide is going to pick up where my earlier &lt;a href="https://www.lostcreekdesigns.co/writing/introduction-to-mapbox-and-react"&gt;Introduction to Mapbox and React post&lt;/a&gt; left off. I have put together a working snippet below filled with comments. I started out trying to explain every last bit of what was happening but think it is a lot more apparent in a lot of ways if I let the code speak for itself. I have provided links to the relevant Mapbox docs which do a much better job of explaining than I ever could. You can also refer to the primer above on sources and layers.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;useRef&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;useEffect&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;mapboxgl&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox-gl&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;SnotelSites&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./lcc_snotel_sites.json&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="c1"&gt;// import the mapbox styles&lt;/span&gt;
&lt;span class="c1"&gt;// alternatively can use a link tag in the head of public/index.html&lt;/span&gt;
&lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/api/&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox-gl/dist/mapbox-gl.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./app.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;

&lt;span class="c1"&gt;// Grab the access token from your Mapbox account&lt;/span&gt;
&lt;span class="c1"&gt;// I typically like to store sensitive things like this&lt;/span&gt;
&lt;span class="c1"&gt;// in a .env file&lt;/span&gt;
&lt;span class="nx"&gt;mapboxgl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;accessToken&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;REACT_APP_MAPBOX_TOKEN&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;mapContainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;useRef&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="c1"&gt;// this is where all of our map logic is going to live&lt;/span&gt;
  &lt;span class="c1"&gt;// adding the empty dependency array ensures that the map&lt;/span&gt;
  &lt;span class="c1"&gt;// is only rendered once&lt;/span&gt;
  &lt;span class="nf"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// create the map and configure it&lt;/span&gt;
    &lt;span class="c1"&gt;// check out the API reference for more options&lt;/span&gt;
    &lt;span class="c1"&gt;// https://docs.mapbox.com/mapbox-gl-js/api/map/&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;mapboxgl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;container&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;mapContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox://styles/mapbox/outdoors-v11&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;center&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;111.75&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;40.581&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="na"&gt;zoom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;pitch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;bearing&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;80&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="c1"&gt;// only want to work with the map after it has fully loaded&lt;/span&gt;
    &lt;span class="c1"&gt;// if you try to add sources and layers before the map has loaded&lt;/span&gt;
    &lt;span class="c1"&gt;// things will not work properly&lt;/span&gt;
    &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;on&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;load&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// add mapbox terrain dem source for 3d terrain rendering&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox-dem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;raster-dem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox://mapbox.mapbox-terrain-dem-v1&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;tileSize&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;512&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;maxZoom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setTerrain&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox-dem&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// avalanche paths source&lt;/span&gt;
      &lt;span class="c1"&gt;// example of how to add a custom tileset hosted on Mapbox&lt;/span&gt;
      &lt;span class="c1"&gt;// you can grab the url from the details page for any tileset&lt;/span&gt;
      &lt;span class="c1"&gt;// you have created in Mapbox studio&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#vector&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;vector&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;url&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;mapbox://lcdesigns.arckuvnm&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// snotel sites source&lt;/span&gt;
      &lt;span class="c1"&gt;// example of using a geojson source&lt;/span&gt;
      &lt;span class="c1"&gt;// data is hosted locally as part of the application&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;SnotelSites&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// bus routes source&lt;/span&gt;
      &lt;span class="c1"&gt;// another example of using a geojson source&lt;/span&gt;
      &lt;span class="c1"&gt;// this time we are hitting an ESRI API that returns&lt;/span&gt;
      &lt;span class="c1"&gt;// data in the geojson format&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addSource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-routes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;data&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;https://opendata.arcgis.com/datasets/4347f3565fbe4d5dbb97b016768b8907_0.geojson&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// avalanche paths - fill layer&lt;/span&gt;
      &lt;span class="c1"&gt;// source-layer can be grabbed from the tileset details page&lt;/span&gt;
      &lt;span class="c1"&gt;// in Mapbox studio&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths-fill&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fill&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;avalanche-paths&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;source-layer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Utah_Avalanche_Paths-9s9ups&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fill-opacity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;fill-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#f05c5c&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// snotel sites - circle layer&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#circle&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites-circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#1d1485&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-radius&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-stroke-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#ffffff&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;circle-stroke-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// snotel sites - label layer&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#symbol&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites-label&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;symbol&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;snotel-sites&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;layout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-field&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;get&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Station Name&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-size&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;16&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-offset&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#1d1485&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-halo-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#ffffff&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;text-halo-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// bus routes - line layer&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#line&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-routes-line&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;source&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;bus-routes&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-color&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#15cc09&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;line-width&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;

      &lt;span class="c1"&gt;// add a sky layer&lt;/span&gt;
      &lt;span class="c1"&gt;// the sky layer is a custom mapbox layer type&lt;/span&gt;
      &lt;span class="c1"&gt;// see https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#sky&lt;/span&gt;
      &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addLayer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
        &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sky&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sky&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;paint&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sky-type&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;atmosphere&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sky-atmosphere-sun&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;90.0&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
          &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;sky-atmosphere-sun-intensity&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;15&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;},&lt;/span&gt;
      &lt;span class="p"&gt;})&lt;/span&gt;
    &lt;span class="p"&gt;})&lt;/span&gt;

    &lt;span class="c1"&gt;// cleanup function to remove map on unmount&lt;/span&gt;
    &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[])&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;ref&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;mapContainer&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;100%&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;100vh&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="nx"&gt;App&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;p&gt;This guide just scratches the surface in terms of the types of sources and layers that can be added to a map using Mapbox GL JS. I encourage you to explore the Mapbox docs and extend my examples. You could try things like...&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tweaking and expanding the layer styling&lt;/li&gt;
&lt;li&gt;adding your own sources and layers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you found this post useful, please retweet, share, or pick up a copy of &lt;a href="https://gumroad.com/l/mapbox-handbook"&gt;The Mapbox Developer's Handbook&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Useful Links and Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://codesandbox.io/s/mapbox-sources-and-layers-y0jsl?file=/src/App.js"&gt;Code Sandbox&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/tylerben/learning-sandbox/tree/master/guides/mapbox-and-react-deep-dive/sources-and-layers-guide"&gt;Github repo for this guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://carto.com/blog/raster-vs-vector-whats-the-difference-which-is-best/"&gt;Vector vs Raster Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/"&gt;Sources Style Spec&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#vector"&gt;Vector source&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/#geojson"&gt;GeoJSON source&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/"&gt;Layers Style Spec&lt;/a&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#fill"&gt;Fill Layer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#circle"&gt;Circle Layer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#symbol"&gt;Symbol Layer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#line"&gt;Line Layer&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/layers/#sky"&gt;Sky Layer&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/style-spec/expressions/"&gt;Mapbox Expressions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://labs.mapbox.com/maki-icons/"&gt;Mapbox Maki Icons&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.mapbox.com/mapbox-gl-js/example/geojson-layer-in-stack/"&gt;Add a new layer below labels&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>react</category>
      <category>javascript</category>
      <category>mapbox</category>
    </item>
    <item>
      <title>Tilesets &amp; Datasets: Managing Data in Mapbox Studio</title>
      <dc:creator>Ben Tyler</dc:creator>
      <pubDate>Mon, 15 Feb 2021 15:51:46 +0000</pubDate>
      <link>https://dev.to/tylerben/tilesets-datasets-managing-data-in-mapbox-studio-352p</link>
      <guid>https://dev.to/tylerben/tilesets-datasets-managing-data-in-mapbox-studio-352p</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This post is part of my &lt;a href="https://gumroad.com/l/mapbox-handbook"&gt;&lt;strong&gt;Building Interactive Maps with React&lt;/strong&gt;&lt;/a&gt; course - a course for anyone wanting to learn how to build interactive maps and integrate them into their React applications. If you enjoy this guide, then chances are you will enjoy the course too!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Thus far we have &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;covered how to create a basic map using Mapbox and React (&lt;a href="https://www.lostcreekdesigns.co/writing/introduction-to-mapbox-and-react"&gt;read post&lt;/a&gt;),&lt;/li&gt;
&lt;li&gt;developed a cheatsheet for the predefined Mapbox Styles (&lt;a href="https://www.lostcreekdesigns.co/writing/mapbox-styles-cheatsheet"&gt;read post&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;covered how to create a custom style in Mapbox Studio and add it to a React app (&lt;a href="https://www.lostcreekdesigns.co/writing/mapbox-studio-creating-an-avalanche-atlas"&gt;read post&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These guides are helpful for establishing some basic familiarity with Mapbox, but only get you so far when the rubber meets the road. If you are building an interactive map, chances are you trying to portray some real data and not just some hello world nonsense.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The aim of this post is to provide an overview of two key features of Mapbox Studio, Tilesets and Datasets and how they can be used to manage and integrate real data into a Mapbox style and application.&lt;/strong&gt; This guide will not provide the ins and outs how to use tilesets and datasets, but instead will focus on providing the context of how they fit into the larger Mapbox ecosystem.&lt;/p&gt;

&lt;h2&gt;
  
  
  Datasets Overview
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbhxqxsqt4nbjf9q91ovx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fbhxqxsqt4nbjf9q91ovx.png" alt="Datasets infographic" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Dataset can a loaded term that means a whole of different things in different contexts. In the context of Mapbox Studio, a dataset refers to an &lt;strong&gt;editable collection of &lt;a href="https://docs.mapbox.com/help/glossary/geojson/"&gt;GeoJSON&lt;/a&gt; features.&lt;/strong&gt; Simplified even further, it is essentially data stored in a JSON that is formatted in a very specific way that also has an added field to capture spatial data ("geometry"). It is the rawest form of data in Mapbox Studio.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;very key point is that Datasets cannot be directly added to a Mapbox Style.&lt;/strong&gt; They first need to be exported as a Tileset. The exported Tileset can then be added easily to a map style. I like to think of datasets as my foundation. I cannot do much with a dataset directly, but I can build a lot of things on top of it.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common Use Cases
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;lightweight spatial data editing/creation&lt;/li&gt;
&lt;li&gt;managing data that has the potential to update regularly&lt;/li&gt;
&lt;li&gt;easy to transform spatial-like data into a true spatial format

&lt;ul&gt;
&lt;li&gt;i.e. converting a CSV with latitude and longitude columns into a tileset&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Drawbacks
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;no bulk editing&lt;/li&gt;
&lt;li&gt;for more complex use cases, you need to learn how to leverage the Datasets and Uploads APIs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To learn the ins and outs of working with datasets, check out the Mapbox &lt;a href="https://docs.mapbox.com/studio-manual/reference/datasets/"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tilesets Overview
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdba44dwpvstudqbrxquq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fdba44dwpvstudqbrxquq.png" alt="Tilesets infographic" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Tilesets are the meat and potatoes of Mapbox Studio. They represent a collection of vector or raster data broken up into a nice uniform square grid of tiles. If you want to add something to a style via Mapbox Studio, you will need to create a tileset for it. Luckily, this is as uploading a shapefile or as easy as exporting a dataset to a tileset most of the time.&lt;/p&gt;

&lt;p&gt;Maybe not 100% accurate, but my model for the differences between Datasets and Tilesets is viewing Datasets like a CSV and Tilesets like a Shapefile. You can view and edit data in a CSV but you cannot do much more than that whereas you view, edit, map, and analyze data in a shapefile.&lt;/p&gt;

&lt;p&gt;To learn the ins and outs of working with Tilesets, check out the Mapbox &lt;a href="https://docs.mapbox.com/studio-manual/reference/tilesets/"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Common Use Cases
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;displaying any sort of non-Mapbox spatial data&lt;/li&gt;
&lt;li&gt;exporting a Dataset for use in a custom Mapbox style&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Drawbacks
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;cannot edit a Tileset&lt;/li&gt;
&lt;li&gt;updating a Tileset usually requires that you re-upload and replace the existing Tileset&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Thinking in Datasets and Tilesets
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3h0bj4ycz1pddkhkugpr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3h0bj4ycz1pddkhkugpr.png" alt="Data flow infographic" width="800" height="359"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When I first started using Mapbox Studio, one of the hardest things to get my head around was the difference between datasets and tilesets and how they fit into the styles editor and Mapbox GL JS. It can be easy to view these three feature sets in isolation, but viewing them as connected steps in a process helped me.&lt;/p&gt;

&lt;p&gt;Here is a common data flow for working with Mapbox Studio.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Find spatial data you want to view and analyze&lt;/li&gt;
&lt;li&gt;Upload spatial data to Mapbox Studio (choose one of the following)

&lt;ol&gt;
&lt;li&gt;Upload data as dataset and then export to a tileset&lt;/li&gt;
&lt;li&gt;Upload data as a tileset&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;li&gt;Edit and manage spatial data in Mapbox Studio&lt;/li&gt;
&lt;li&gt;Add spatial data to a Mapbox Style&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;One of the things that initially tripped me up was deciding when to use Datasets and when to use a Tileset as both are valid entry points into the data workflow. My general rule of thumb is that if I want a nice UI to make simple edits to my spatial data, I will reach for Datasets, otherwise I reach for Tilesets.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Real World Example
&lt;/h2&gt;

&lt;p&gt;Now that I have provided an overview of Datasets, Tilesets, and how they fit together in theory, I will provide an actual use case from a data-driven mapping application I have built.&lt;/p&gt;

&lt;p&gt;I recently built an application that allows users to see places where they can trail run, fish, and grab a beer afterwards. There are a couple of key spatial datasets that this application relies on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the course data (line strings representing the trail/path the user can run along)&lt;/li&gt;
&lt;li&gt;watershed boundaries (polygons representing the fisheries)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Deciding What to Use
&lt;/h3&gt;

&lt;p&gt;One of the other rules of thumbs I use when determining if I should use a Dataset or a Tileset is the frequency that the data will need to be updated. If it is on the more frequent side of things, I will opt to use a Dataset.&lt;/p&gt;

&lt;p&gt;For this example, I knew the course data would change over time as more places to run and fish got added to the application so I opted to manage this data as a Dataset. The watershed boundaries are not likely to change (barring some massive earthquake or geologic event) and represent a perfect use case for a Tileset.&lt;/p&gt;

&lt;h3&gt;
  
  
  Getting the Data into Studio
&lt;/h3&gt;

&lt;p&gt;When I started building the application, I already had a lot of the course data available as GPX files from Strava. You unfortunately cannot upload GPXs as a tileset so I had to convert these to GeoJSON first. After doing so, I uploaded the course data as a Dataset using Mapbox studio. Once I had all my courses added, I exported them to a Tileset. When I needed to add new courses, I opened up my existing Dataset and used the import feature to bring in the additional courses.&lt;/p&gt;

&lt;p&gt;Adding in the watershed boundaries was even easier. I just navigated to the &lt;a href="https://studio.mapbox.com/tilesets/"&gt;Tilesets page&lt;/a&gt; in Mapbox Studio and uploaded a shapefile I had that contained the watershed boundaries.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding the Data to a Mapbox Style
&lt;/h3&gt;

&lt;p&gt;With both of key spatial components now available as Tilesets, all that was left to do was to create a custom Mapbox style and add my two Tilesets. If you want to learn how to add a Tileset to a Mapbox Style, make sure to check out &lt;a href="https://www.lostcreekdesigns.co/writing/mapbox-studio-creating-an-avalanche-atlas"&gt;this guide&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding the Style to a React App
&lt;/h3&gt;

&lt;p&gt;Once the Tilesets were added to my custom Mapbox Style, the only remaining task was integrating the Style into my React frontend. For a guide on how to do this, please refer to my earlier post, &lt;a href="https://www.lostcreekdesigns.co/writing/introduction-to-mapbox-and-react"&gt;Introduction to Mapbox and React&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Next Steps
&lt;/h3&gt;

&lt;p&gt;The above workflow is a simplified version of what I implemented. On the final versions of the app, I got the chance to leverage some really cool Mapbox products like the Uploads and Datasets API. I will most likely cover this in a future post though so stay tuned!&lt;/p&gt;

&lt;p&gt;If you found this post useful, please retweet, share, or pick up a copy of &lt;a href="https://gumroad.com/l/mapbox-handbook"&gt;The Mapbox Developer's Handbook&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Useful Links and Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Datasets Docs (&lt;a href="https://docs.mapbox.com/studio-manual/reference/datasets/"&gt;https://docs.mapbox.com/studio-manual/reference/datasets/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Tilesets Docs (&lt;a href="https://docs.mapbox.com/studio-manual/reference/tilesets/"&gt;https://docs.mapbox.com/studio-manual/reference/tilesets/&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>react</category>
      <category>javascript</category>
      <category>mapbox</category>
    </item>
    <item>
      <title>Mapbox Studio: Custom Styles and Creating an Avalanche Atlas</title>
      <dc:creator>Ben Tyler</dc:creator>
      <pubDate>Mon, 08 Feb 2021 17:41:50 +0000</pubDate>
      <link>https://dev.to/tylerben/mapbox-studio-creating-an-avalanche-atlas-4ac7</link>
      <guid>https://dev.to/tylerben/mapbox-studio-creating-an-avalanche-atlas-4ac7</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This post is part of my &lt;a href="https://gumroad.com/l/mapbox-handbook"&gt;&lt;strong&gt;Building Interactive Maps with React&lt;/strong&gt;&lt;/a&gt; course - a course for anyone wanting to learn how to build interactive maps and integrate them into their React applications. If you enjoy this guide, then chances are you will enjoy the course too!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;The aim of this post is to walk you through how you can create a custom map using Mapbox Studio and then add that map to a React application.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;There are a lot of cool maps out there in the outdoor industry and natural resource management fields. One of my favorite map types though are avalanche atlases. They give you an intimate glimpse into where the fiery white dragons have historically reared their heads most frequently.&lt;/p&gt;

&lt;p&gt;We will be using Mapbox Studio to develop our own avalanche atlas for Little and Big Cottonwood Canyons. These canyons are fabled for their avalanche activity as well as the science and art of avalanche control that have grown out of it. It makes you appreciate all of the hard work of the Utah Avalanche Center, transportation departments, and ski patrol that help keep these corridors open.&lt;/p&gt;

&lt;p&gt;Here is a glimpse at the atlas we will be building.&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F73d1rezycvw7vgtlzfj5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F73d1rezycvw7vgtlzfj5.jpg" alt="Avalanche Atlas Preview" width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Introduction to Mapbox Studio
&lt;/h2&gt;

&lt;p&gt;If you have not worked with Mapbox Studio before, here is a quick primer. Studio is a browser based application that allows you create just about any type of map you can dream up. You can start with one of the predefined styles I covered in my &lt;a href="https://www.lostcreekdesigns.co/writing/mapbox-styles-cheatsheet"&gt;Mapbox Styles Cheatsheet&lt;/a&gt; or start from scratch.  Like probably most people, my first introduction to GIS was through ArcMap. A powerful program for sure, but one that left me incredibly frustrated that I could not customize basemaps. With Mapbox studio, you can customize the appearance of just about any map layer, all the way down to how tiny features like how park labels are displayed.&lt;/p&gt;

&lt;p&gt;These guide will not be an exhaustive introduction to studio. Mapbox has already provided great documentation on the subject and I would risk rambling on and on with the end result being a worse product. It is definitely worth stepping through their guides which can be found at &lt;a href="https://docs.mapbox.com/studio-manual/guides/"&gt;https://docs.mapbox.com/studio-manual/guides/&lt;/a&gt;.&lt;/p&gt;
&lt;h2&gt;
  
  
  Building the Avalanche Atlas
&lt;/h2&gt;
&lt;h3&gt;
  
  
  What is an avalanche atlas?
&lt;/h3&gt;

&lt;p&gt;An avalanche atlas is a map or collection of maps that portrays avalanche hazard. Not only can they show where avalanches have been known to occur, they can provide technical information like distance to major roadways, starting zone elevation, etc. They can be an incredibly powerful tool for risk mitigation and land use planning. &lt;/p&gt;
&lt;h3&gt;
  
  
  Initial Setup
&lt;/h3&gt;

&lt;p&gt;To get started, head on over to &lt;a href="https://www.mapbox.com/"&gt;https://www.mapbox.com/&lt;/a&gt; and login to your account (create one now if you do not already have one). After logging in, head on over to the Studio home page at &lt;a href="https://studio.mapbox.com/"&gt;https://studio.mapbox.com/&lt;/a&gt; and click on the "New Style" button. This will open up a modal where you can choose a template to use for the map. Since we are building a map that is focused on the natural world and visualizing accurate representations of terrain, I think it makes sense to select the "Satellite Streets" style.&lt;/p&gt;
&lt;h3&gt;
  
  
  Getting Familiar with the Mapbox Studio UI
&lt;/h3&gt;

&lt;p&gt;The user interface for Studio can be a bit intimidating at first (it used to be even more so before the introduction of the "Components" and "Layers" concepts). I think the Mapbox team has done a great job of masking the complexity in Studio. Once you get your feet wet, you will likely be amazed at how powerful the tool is.&lt;/p&gt;

&lt;p&gt;Anyways, let's get acquainted with the aspects of the UI that will be our bread and butter. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The sidebar provides accesse to &lt;strong&gt;Components&lt;/strong&gt; and &lt;strong&gt;Layers.&lt;/strong&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Components&lt;/strong&gt; groups together similar layer groups for easy styling (check out this &lt;a href="https://docs.mapbox.com/studio-manual/guides/components/"&gt;guide&lt;/a&gt; for more info).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Layers&lt;/strong&gt; provide a more granular view of the individual layers that make up the style and exposes a lot of controls for each.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;top application bar&lt;/strong&gt; contains a whole slew of map style settings.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;Search and Zoom Controls&lt;/strong&gt; in the upper right cornerprovide an easy way to navigate around the map&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Use the search bar to search for "Little Cottonwood Canyon" and then select it from the search suggestions. This will pop us over to area that we are creating an avalanche atlas for. Take a little time here to get familiar with the UI and the map.&lt;/p&gt;
&lt;h3&gt;
  
  
  Adding the Avalanche Paths Layer to the Map
&lt;/h3&gt;

&lt;p&gt;Time to add the avalanche paths. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download the GeoJSON file that contains the slide paths from &lt;a href="https://github.com/tylerben/learning-sandbox/blob/master/guides/mapbox-and-react-deep-dive/spatial-data/Utah_Avalanche_Paths.geojson"&gt;here&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Find the "Layers" tab in the left sidebar and click on the "+" button. From this UI, you can add previously uploaded data to the map or upload new data. We are going to upload some new data.&lt;/li&gt;
&lt;li&gt;Click "Upload data". The file picker allows us to upload a whole slew of spatial data formats such as MBTiles, KML, GPX, GeoJSON, Shapefile (zipped), or CSV file for vector tiles and GeoTIFF files for raster tiles. Upload the avalanche paths GeoJSON file and click confirm. Note: a future post will take a deeper dive into Mapbox tilesets and datasets.&lt;/li&gt;
&lt;li&gt;The file will take a few minutes to upload and process. After the upload has finished processing, click on the input below the "Source" label. This open up a dialog where you can select the avalanche paths we just uploaded. Find the source in the list and select it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We are currently in the "Data" view for our layer. We will gloss over all the functionality exposed here but you can do all sorts of things like specify the geometry type, filter features, and control the zoom range at which the layer is visible.&lt;/p&gt;
&lt;h3&gt;
  
  
  Styling the Avalanche Paths
&lt;/h3&gt;

&lt;p&gt;Now that we have the avalanche paths layer added to our map, we can style it. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click on the "Style" tab to the left of the "Select Data" tab. If you zoom out a bit on the map, you should see all of our avalanche paths as solid black polygons on the map. There sure are a lot of them!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Time to make these look a whole lot better! &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select the "Color" item from the "Style" pane, you should see a color picker. We will want to change the fill color to a nice red and add some transparency to the polygons. I personally like the color &lt;code&gt;#ec2222&lt;/code&gt; and an opacity of 45 (use the opacity slider directly below the color picker or the input to the right of the slider).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Looking much better! It really gives you an appreciation for just how many avalanche paths intersect the roadways in these canyons and the crazy hard work that the avalanche centers and transportation departments are tasked with.&lt;/p&gt;
&lt;h3&gt;
  
  
  Bonus: Viewing the Avalanche Paths in 3D
&lt;/h3&gt;

&lt;p&gt;This is a brand spanking new feature in Mapbox Studio, but you can now render 3D terrain (see my &lt;a href="https://www.lostcreekdesigns.co/writing/building-a-3d-react-map-component"&gt;earlier post&lt;/a&gt;). For a use case like avalanche slide paths, being able to visualize them in 3D is such a step up. Here is how to do so.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click "Terrain" in the top navigation bar and flip the toggle that says "Enable 3D Terrain".&lt;/li&gt;
&lt;li&gt;Adjust the pitch of the map camera by holding down the Control/Ctrl key and moving your mouse forward and back to your liking (reverse these steps to go back to 2D).&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Soaking It All Up
&lt;/h3&gt;

&lt;p&gt;All in all, a pretty simple process to create our own custom map! I encourage you to take some time to explore Studio before moving on to the next steps.&lt;/p&gt;
&lt;h2&gt;
  
  
  Adding the Custom Style to a React Application
&lt;/h2&gt;

&lt;p&gt;I wrote an &lt;a href="https://www.lostcreekdesigns.co/writing/introduction-to-mapbox-and-react"&gt;earlier post&lt;/a&gt; as part of this series that illustrated how to create a basic interactive map using Mapbox and React. This next step builds off of that tutorial so if you have not read it and are not overly familiar with Mapbox GL JS, definitely give it a read.&lt;/p&gt;

&lt;p&gt;Similarly to how it is easy to swap out predefined Mapbox styles in our application, it is just as easy to add in our own style. In Mapbox Studio, &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Click "Publish" in the upper righthand corner.&lt;/li&gt;
&lt;li&gt;Walk through the steps in the dialog to publish the map.&lt;/li&gt;
&lt;li&gt;After it is published, click the "Share" item immediately to the left of the "Publish" button.&lt;/li&gt;
&lt;li&gt;In the subsequent dialog, look for the section titled "Developer resources" and find the form input labelled "Style URL". Copy this url.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now in your React application, where the snippet where you initialize your map. It should look something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;&lt;span class="c1"&gt;// create the map and configure it&lt;/span&gt;
&lt;span class="c1"&gt;// check out the API reference for more options&lt;/span&gt;
&lt;span class="c1"&gt;// https://docs.mapbox.com/mapbox-gl-js/api/map/&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;map&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;mapboxgl&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;container&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;mapContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;current&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;YOUR STYLE URL HERE&amp;gt;&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// TODO REPLACE ME&lt;/span&gt;
  &lt;span class="na"&gt;center&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="mf"&gt;111.676&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;40.549&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
  &lt;span class="na"&gt;zoom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;13&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All you have to do now is the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;paste the copied Style URL into the &lt;code&gt;style&lt;/code&gt; property on the map config.&lt;/li&gt;
&lt;li&gt;find a zoom and map center you like by panning the map around in Studio. Copy the zoom level and coordinates from the top application bar. Set the &lt;code&gt;zoom&lt;/code&gt; and &lt;code&gt;center&lt;/code&gt; properties to these accordingly.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Save your work, start up the app, and you should now be seeing your very own avalanche atlas for Big and Little Cottonwood Canyons.&lt;/p&gt;

&lt;p&gt;If you found this post useful, please retweet, share, or pick up a copy of &lt;a href="https://gumroad.com/l/mapbox-handbook"&gt;The Mapbox Developer's Handbook&lt;/a&gt;!&lt;/p&gt;

&lt;h2&gt;
  
  
  Next Steps
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;try customizing some of the other map layers&lt;/li&gt;
&lt;li&gt;try labelling the avalanche slide paths&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Useful Links and Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Mapbox Studio Home Page (&lt;a href="https://studio.mapbox.com/"&gt;https://studio.mapbox.com/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Mapbox Studio Guides (&lt;a href="https://docs.mapbox.com/studio-manual/guides/"&gt;https://docs.mapbox.com/studio-manual/guides/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Mapbox Style Components (&lt;a href="https://docs.mapbox.com/studio-manual/guides/components/"&gt;https://docs.mapbox.com/studio-manual/guides/components/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Source for the Avalanche Paths (&lt;a href="https://opendata.gis.utah.gov/datasets/utah-avalanche-paths"&gt;https://opendata.gis.utah.gov/datasets/utah-avalanche-paths&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Utah Avalanche Center (&lt;a href="https://utahavalanchecenter.org/"&gt;https://utahavalanchecenter.org/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;More info on Avalanche Atlases (&lt;a href="https://instaar.colorado.edu/research/publications/occasional-papers/avalanche-atlas-san-juan-county-colorado/"&gt;https://instaar.colorado.edu/research/publications/occasional-papers/avalanche-atlas-san-juan-county-colorado/&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;One of my personal favorite podcasts. All about avalanches (&lt;a href="https://www.theavalanchehour.com/"&gt;https://www.theavalanchehour.com/&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>react</category>
      <category>javascript</category>
      <category>mapbox</category>
    </item>
  </channel>
</rss>
