1. 5
    Section 02 - Adding Your First React Leaflet Map to a New React Application
    1m 14s

Section 02 - Adding Your First React Leaflet Map to a New React Application

Colby Fayock
InstructorColby Fayock
Share this video with your friends

Social Share Links

Send Tweet

We just learned about how maps can have huge impacts on people's lives. Inspiring? I sure think so!

Now that we're ready, we're going to get started by installing our dependencies and actually add a map to our page. That way, all of our hungry customers can easily search the map for their favorite locations.

Instructor: [0:00] Hey, mappers. Welcome to lesson two. Here, we're going to learn how to add a map to our app. Starting with exercise one, the first thing we need to do is install our dependencies. For building maps, we have two core dependencies that we'll install using npm. Our dependencies are Leaflet and React-Leaflet.

[0:14] Leaflet is the core API that we'll use to build our map. It's the most popular out there in the mapping community. Lucky for us, Leaflet is also available as a library of React components. We'll use a React-Leaflet to build the foundation of our map. Once you have your dependencies installed, we should be ready for exercise two.

[0:30] For our second exercise, we'll add our map to the app. In order to add our map, we need two primary components. Those components are our Map component and our tileLayer component.

[0:38] Our Map will provide the foundation of our map. Think of it like you're mounting a React app to a div, while our tileLayer component will be what provides the map imagery. We'll import both of these from React-Leaflet to add to our map.

[0:49] We'll be primarily working in the App.js and App.css file. For a little extra credit, we're going to make our map take up the entire screen. When adding our map, we'll notice a gap around the sides. We want our customers to have as much space as possible to see the map. We'll use some CSS to make this change. We can add those styles right to the main App.css file. Are you ready to get started?

[1:09] After this, you should have successfully added your first map to the app. Have fun with this lesson, and good luck.