Building an interactive map with Google Maps Platform and React - Crash Course

Looking for a crash course on how to build amazing, interactive maps with React and Google Maps Platform? In this video, Leigh Halliday - Engineering manager at Wrapbook - teaches you how to take your maps to the next level. He’ll discuss the basics of using Google Maps in React, how to cluster markers, apply custom styles using a Map ID, and more. Watch this video for a crash course in using React with Google Maps!
Subscribe to the Google Maps Platform KZread → goo.gle/GMapsPlatform
Follow Google Maps Platform on Twitter → goo.gle/GoogleMapsTwitter
Check out Google Maps Platform’s blog → goo.gle/33YHvRV
Source code → goo.gle/3K7y07Z
Starter code → goo.gle/3IDkfxu
Chapters:
00:00 - Introduction
01:25 - Loading Google Maps Script
05:30 - Rendering Google Map in React
15:40 - Customizing Styles & Map ID
19:35 - Google Places Search
31:30 - Displaying Office Marker
34:40 - Showing Circles on Map
36:45 - Rendering Houses
39:35 - Clustering Markers
40:55 - Displaying Directions
47:15 - Calculating Distance and Time

Пікірлер: 171

  • @zb2747
    @zb27472 жыл бұрын

    Couldn’t come at a better time as I’m working on a project that uses google api- your previous tutorials are the best google maps api tutorials

  • @leighhalliday

    @leighhalliday

    2 жыл бұрын

    Amazing!! I tried with this one to touch a couple of different APIs from the last one: Directions, Clustering, MapID... I hope you like it!

  • @tanvirazhar
    @tanvirazhar Жыл бұрын

    So grateful that I have found this tuts. Leigh, you are doing gods work here. Thanks heaps for rescuing us!!!!!

  • @christopherreif3624
    @christopherreif3624 Жыл бұрын

    You sir are a God sent! Thank you for such a great video. I've had so many problems with other tutorials, but your Google Maps series has helped so much! I really appreciate your videos!!!

  • @daniel-nagy
    @daniel-nagy2 жыл бұрын

    One of the best videos on your channel. I've learned so much in just 1 hour. Keep up the good work Leigh!

  • @leighhalliday

    @leighhalliday

    2 жыл бұрын

    Amazing! Thanks so much Daniel!

  • @belkocik
    @belkocik Жыл бұрын

    The courses no1 makes these days! pure gold!

  • @benzz22126
    @benzz221262 жыл бұрын

    best starter tutorial for google maps in react . thank you for this valuable content !!!

  • @nicholasroman8071
    @nicholasroman80718 ай бұрын

    Thank you! This tutorial has accelerated my learning curve regarding google maps.

  • @mm93249
    @mm932495 ай бұрын

    This was such a good demo and scenario! Thank you Leigh.

  • @LuthandoMaqondo
    @LuthandoMaqondo2 жыл бұрын

    The best video on ReactJS and Google Maps & Place API. Thank you Sir.

  • @nirajankarki275
    @nirajankarki2756 ай бұрын

    Very useful video about using google map in react project. Thank you so much Leigh !

  • @willettelaland6318
    @willettelaland6318 Жыл бұрын

    This is absolutly working for 100% sure.enjoy it.Thank you.

  • @ricardomagalhaes6777
    @ricardomagalhaes67772 жыл бұрын

    What a fantastic tutorial, thank you so much Leigh. I think this may even be my first KZread comment in 10 years! Answered so many questions I had about modern usage of some Maps APIs with React, fantastic stuff. The only thing I had to tweak from your code was making the generateHouses() fn take the `office` and not the `center`, since the `center` is never updated apart from the initial page load (so the houses would always be generated away from your office location, if it were different than your initial `center`). Just in case anyone else was struggling with that :) thanks again, phenomenal tutorial!

  • @everObvious

    @everObvious

    Жыл бұрын

    I was wondering about that very thing! Additionally, I set the default value for office to center (after reordering those lines of code, of course).

  • @murilodutra4887
    @murilodutra4887 Жыл бұрын

    Gosh, you're incredible man. Thanks for sharing your knowledge!!!

  • @dailylife2170
    @dailylife2170 Жыл бұрын

    Never saw such well explained video thanks you ❤️❤️❤️

  • @outis99
    @outis992 жыл бұрын

    These are the kind of tutorials I love! I'm tired of looking up a new technology and seeing the same tutorial over and over again Will definitely switch to this package and follow part of your tutorial Love the thumbnail btw 🤣

  • @leighhalliday

    @leighhalliday

    2 жыл бұрын

    Thanks for the kind feedback!! Glad you enjoyed it!

  • @mohammadsubhan1318
    @mohammadsubhan13184 ай бұрын

    Thankyou for sharing such valuable information... I really needed this! 🤩

  • @JeatBunkie
    @JeatBunkie Жыл бұрын

    So glad I found you channel man!

  • @anassaleem8500
    @anassaleem85002 жыл бұрын

    Great videos learned a lot of things through this video. Thanks to you Leigh Halliday. Please make a video on Geofencing

  • @gazizbay4082
    @gazizbay4082 Жыл бұрын

    Thanks for everything your the great man, stay healthy bro! You are the best

  • @ryadean
    @ryadean2 жыл бұрын

    I already know this is gonna be good! Thanks Leigh.

  • @leighhalliday

    @leighhalliday

    2 жыл бұрын

    Haha thanks Ryan, did it live up to expectations?

  • @ryadean

    @ryadean

    2 жыл бұрын

    @@leighhalliday Of course Leigh, you never disappoint!

  • @yohanaasintha5562
    @yohanaasintha5562 Жыл бұрын

    Thank you, It was really helpful.

  • @aleksandarmojsic168
    @aleksandarmojsic1682 жыл бұрын

    Great video! Thank you!

  • @grassia423
    @grassia423 Жыл бұрын

    This is amazing video with a lot of great helpful works very you.

  • @adaichesunday4104
    @adaichesunday4104 Жыл бұрын

    Nice tutorial.... Very helpful

  • @salamanca6305
    @salamanca6305 Жыл бұрын

    Stellar content, as always

  • @franktfrisby
    @franktfrisby Жыл бұрын

    this is a product in itself. very nice

  • @yjyou7780
    @yjyou7780 Жыл бұрын

    You saved me sir. Thank you.

  • @willyhorizont8672
    @willyhorizont86722 жыл бұрын

    Wow nice tutorial sir. Very useful

  • @anirup.patnaik
    @anirup.patnaik4 ай бұрын

    This is just amazing. Thanks

  • @leighhalliday

    @leighhalliday

    3 ай бұрын

    Glad you like it!

  • @RomiLenoir
    @RomiLenoir Жыл бұрын

    Exactly what I was looking for! Just need some minor changes. Thanks a lot

  • @hadisiswanto1062
    @hadisiswanto10622 жыл бұрын

    Mantab Om Hall.. matur suwun

  • @chrystianespinoza922
    @chrystianespinoza922 Жыл бұрын

    watcNice tutorialng one or two every night, SUPER helpful, cNice tutorialll and clear. Great content, can't wait to watch them all.

  • @kasperbirch3263
    @kasperbirch32632 жыл бұрын

    This is very useful, Thank you very much 🙏

  • @leighhalliday

    @leighhalliday

    2 жыл бұрын

    Thank you Kasper, glad it was useful!

  • @Boylee_
    @Boylee_ Жыл бұрын

    Good guide for beginners)

  • @sarnarider9872
    @sarnarider9872 Жыл бұрын

    TNice tutorials was honestly so helpful. I’ve been working around soft, whether it be church, singing in a band, or theatre for most of my life so tNice tutorials

  • @albab790
    @albab790 Жыл бұрын

    Thank you so much

  • @user-cw1fz2mj6u
    @user-cw1fz2mj6u8 ай бұрын

    nice tutorial

  • @Randomblues277
    @Randomblues2772 жыл бұрын

    For those having issues with markers for house not rendering around the work location. Try using the tweaked useMemo below instead const houses = useMemo(function(){ if(office) return generateHouses(office); },[office]);

  • @demetriusguidry6431

    @demetriusguidry6431

    Жыл бұрын

    What is the code if you want display in "miles" instead of "km"

  • @lukeshieldsnature

    @lukeshieldsnature

    4 ай бұрын

    Awesome thanks makes sense

  • @Kathrual
    @Kathrual2 жыл бұрын

    Hey thanks for this tutorial, working with react is kind of amazing when you can create something like this in minutes. I have a problem though when using strictmode=true the directionrenderer kinda gets called twice and then renders the old direction (first; if new building selected) and I am not really sure why. I mean with strictmode: false everything works it is just a little confusing to me.

  • @AbdelhameedG
    @AbdelhameedG2 жыл бұрын

    Are you looking for the best google maps turorials on youtube ? Leigh Haliday , no doubt , Thanks man. would love to see you doing more tutorials.

  • @leighhalliday

    @leighhalliday

    2 жыл бұрын

    Thank you Abdelhamid! I appreciate the kind words!

  • @gerardbanaag1951
    @gerardbanaag1951 Жыл бұрын

    one and only easy and working method

  • @dziugasgiedraitis2394
    @dziugasgiedraitis2394 Жыл бұрын

    GG finally something that works

  • @alexg7282
    @alexg72822 жыл бұрын

    Thank you !

  • @leighhalliday

    @leighhalliday

    2 жыл бұрын

    Thank you Alex! Hope you enjoyed it!

  • @Lovedeep555
    @Lovedeep555 Жыл бұрын

    Thank you very much for making amazing map videos, @Leigh Halliday, I have a question or we can say doubt if you can answer, I am experimenting on a map project, where we will have 15 million markers on the map, we are simplly adding them on the map via array.map function, which is the straightforward thing, but here is the challenge we have a filter UI where we have checkboxes, to hide/show markers based on their category, everytime we want to hide/show some markers, we filter the main array, which causes the state change, and all the 15M marker start rendering again, because of that state change, which causes the freezing issue, what do you think is the way to optimize the performance?

  • @rayenhidri584
    @rayenhidri5842 жыл бұрын

    Thx, Bravo

  • @karinagabrielaserranorodri5646
    @karinagabrielaserranorodri5646 Жыл бұрын

    you! SO MUCH THX!

  • @spongebob93lover
    @spongebob93lover2 жыл бұрын

    Great video! just a question, can we customize the cluster icon style? How do we do that?

  • @zamanEhsani
    @zamanEhsani Жыл бұрын

    hey Leight, your videos are perfect. I recently i have to make a react app what need a map to render. I choose to use google map. But since i am new to the world of map and how maps are made and rendered specially with react and google map, I was wondering if the react-google-map/api is the right package to choose? I have also seen it's documentation, it is not that much and not a big community. Could please state why are you using it? and the pros and cons of it?

  • @user-it1cj5gy7m
    @user-it1cj5gy7m2 жыл бұрын

    I tried to do this as explaining it but all I can see is Commute? and Map on this page I don't think so but does it work on only Mac? I'm begginer.. (Anyway this lecture is so clear that I can understand the logic!! I love this!!)

  • @AdamHollister
    @AdamHollister2 жыл бұрын

    haha good timing. Just about to start a very similar project

  • @leighhalliday

    @leighhalliday

    2 жыл бұрын

    Hope it helps :)

  • @nicholasbraveson1173
    @nicholasbraveson11735 ай бұрын

    Hey Leigh, I really appreciate your tutorial and the work you've done. I just have one problem in my project on which I cant find any workarouds/solutions. I have current user pin and I want it to behave exactly like in google maps ( Follow user, move map position, smooth transition, etc... ) do you have perhaps any tutorial on this subject?

  • @TheVGJournal
    @TheVGJournal Жыл бұрын

    Awesome tutorial, love your stuff! I am having an issue with the map styles, though. When I run my dev app on my phone, I get a TypeError. I know it has to do with the "mapId" in the options object, because when I comment it out, I get no error, and it works flawlessly. It seems to work on web, no problem, but on my phone, I get the error message. Also, when I pan and zoom to different locations, its also blurry (This does not happen with the default map styles). As I said before, the pan and zoom is flawless on web, the error is on my phone specifically. Sorry to ask, but I couldn't find anything helpful online. Thanks and great work!!

  • @jeffinj7707
    @jeffinj77072 жыл бұрын

    How can we add a marker and set the orientation based on the direction. Like uber's car marker moving towards the direction. thanks

  • @markespedido4354
    @markespedido4354 Жыл бұрын

    nice

  • @nath0x_
    @nath0x_ Жыл бұрын

    Great video, thanks Leigh! I have some questions about making some customizations to the route generated. First, I wonder if it is possible to access the start and end markers of the route in order to change their icons and style. Second, it is possible to give a different pattern to the line generated and how it can be shown as in 3D. Third, it is possible to click on the route generated in order to show some info window.

  • @bogdangaafiga4056
    @bogdangaafiga4056 Жыл бұрын

    cool!

  • @moniqueanncamillegarcia1797
    @moniqueanncamillegarcia1797 Жыл бұрын

    Nice

  • @benzz22126
    @benzz221262 жыл бұрын

    hi im trying to follow your code but only with javascript...im stuck at the panTo section. I get an error saying panTo is not a function

  • @RishiMohinani
    @RishiMohinani6 ай бұрын

    which file we've to run to start our project

  • @niwasikajhos
    @niwasikajhos2 жыл бұрын

    I was have no idea to use useMemo on every item to re render map, and mostly i use useEffect when these need to get rerender, many thanks sir, however the packages is different but it's very helpfully

  • @leighhalliday

    @leighhalliday

    2 жыл бұрын

    Glad it helped Niwasika! Sometimes useMemo isn't required, it depends if the underlying component (GoogleMap in this case) is doing a shallow comparison or a deep comparison. If you do `{} === {}` in JavaScript, it's actually false, because you are comparing 2 different objects, who just happen to have the same contents... so if you need them to be identical, you can use the useMemo hook for that.

  • @koa1663
    @koa1663 Жыл бұрын

    can does this include navigation from the user's GPS?

  • @shinobi_coder88
    @shinobi_coder8811 ай бұрын

    Hi Leigh, is there any way for me to use it's API without entering Billing Info? It stressed me out tho to have to deal with it

  • @mohamedusama6375
    @mohamedusama637516 сағат бұрын

    hi sir , i have some doubt in fetch direction , acording your code ui direction is pointing A to B even for me from lat & lang or coming correctly nut ui drection is connenting , can give me solutions for this ...

  • @user-jz2lz8fd3z
    @user-jz2lz8fd3z4 ай бұрын

    Leigh Halliday thanks for this great piece work, i just have a question: Can the centre be the original/live position of the user.

  • @leighhalliday

    @leighhalliday

    3 ай бұрын

    Yea! You'll need to use the browser geolocation functionality... that said, the user may not grant you access to it.

  • @adityasharma9983
    @adityasharma99832 жыл бұрын

    how we can use our distance mapping algorithm in this application ???

  • @k.aleksanderwyszynski9168
    @k.aleksanderwyszynski91682 жыл бұрын

    Hey there, another great tutorial! Q: if we drag markers around on the map, how would we get the new location into state?

  • @azeezadewale2749

    @azeezadewale2749

    Жыл бұрын

    yourFunction(e)} draggable={true} /> and then extract lat and lng from the event (e) object in the function you create i.e. yourFunction. and target e.latLng.lat(), e.latLng.lng()

  • @geosystems2106
    @geosystems2106 Жыл бұрын

    Please clarify if the goggle-maps-api package is mandatory for react or not ?

  • @justfly1984
    @justfly19842 жыл бұрын

    Sorry for interruption, but then you build your frontend app, your env vars for frontend is packaged by bundler into the code, so there is no issue to use key in place. You should protect your key by limiting domain names per key instead.

  • @leighhalliday

    @leighhalliday

    2 жыл бұрын

    You're right, but I think it's a good habit to get in to! Especially for public repos on GitHub, having API keys exposed makes them pretty easy to find, and if you accidentally leave a backend key exposed, you're in big trouble! Better to practice good "key hygiene" all around, which I think means keeping them in ENV vars, and also limiting them to domains like you said.

  • @JM-og9ph
    @JM-og9ph Жыл бұрын

    worked for . On default it was at Agressive TE for but I clicked to the right

  • @PoojaBhandaribanaula
    @PoojaBhandaribanaulaАй бұрын

    i want exact latitude and longitude but not getting in chrome browser other browser getting fine .so how to make all browser compatible.

  • @learnwithkiranthami
    @learnwithkiranthami Жыл бұрын

    in soft rolls?sorry in my English.I hope you can help

  • @orioldemo5380
    @orioldemo5380 Жыл бұрын

    how to colour states of a country using this library ? Please help !

  • @yuliiasvystak1644
    @yuliiasvystak164410 ай бұрын

    How can I delete Circle when user click outside map?

  • @timoteostifft7847
    @timoteostifft78472 жыл бұрын

    top content

  • @antoparjiyo2785
    @antoparjiyo2785 Жыл бұрын

    Can you use soft from soft soft to make profit?

  • @brucegreentree6190
    @brucegreentree61902 ай бұрын

    So awesome

  • @demetriusguidry6431
    @demetriusguidry6431 Жыл бұрын

    What is the code if you want display in "miles" instead of "km"

  • @pb8655
    @pb8655 Жыл бұрын

    I've been struggling with using a custom component as a marker. Everywhere I go says just pass in lat lng props to the children and the maps will handle the rest but that's not happening + typescript it throwing an error :(

  • @abdelhameedhamdy
    @abdelhameedhamdy2 жыл бұрын

    Very neat .. just wondering do you prefer mapbox or Google maps for a spatial app !!

  • @leighhalliday

    @leighhalliday

    2 жыл бұрын

    Both are great! For me Google Maps is the standard, performant, great API, the OG, but MapBox is great too! We're really spoiled as developers these days.

  • @nikako1889
    @nikako1889 Жыл бұрын

    which vscode theme do you use?

  • @mukulsoni8263
    @mukulsoni8263 Жыл бұрын

    Facing this error: React Hook "useLoadScript" is called in function "map" that is neither a React function component nor a custom React Hook function. React component names must start with an uppercase letter. React Hook names must start with the word "use" react-hooks/rules-of-hooks

  • @guillermojimenez6581
    @guillermojimenez6581 Жыл бұрын

    Hi, how can I re-render polylines sir ?

  • @leonardofabioacevedo2566
    @leonardofabioacevedo2566 Жыл бұрын

    Alguien me puede orientar de como hacer para ubicar autos en el mapa en java. donde me puedo dirigir para investigar eso. Gracias

  • @chanzerone9217
    @chanzerone921717 күн бұрын

    what's your vscode theme?

  • @jeandamour-js7es
    @jeandamour-js7es2 ай бұрын

    amazing

  • @jatinawasthi2647
    @jatinawasthi2647 Жыл бұрын

    I recomnd you two to buy the Producer Edition (And if you have got money, buy the Full Bundle)

  • @codingroom928
    @codingroom928 Жыл бұрын

    why am i get 'Cannot read properties of undefined (reading 'maps')' ...

  • @Samuelrajsams
    @SamuelrajsamsАй бұрын

    Hi Guys, I have a requirement in my application, need to show construction zone in Google Maps API. Can you please help me on this

  • @kacperm8450
    @kacperm8450 Жыл бұрын

    Leigh, help please. Why is the MarkerClusterer not working anymore ? No overload matches this call. Overload 1 of 2, '(props: MarkerClustererProps | Readonly): ClustererComponent', gave the following error. Type 'Element[]' is missing the following properties from type 'Element': type, props, key Overload 2 of 2, '(props: MarkerClustererProps, context: any): ClustererComponent', gave the following error. Type 'Element[]' is not assignable to type 'Element'.ts(2769) index.d.ts(378, 15): The expected type comes from the return type of this signature. index.d.ts(378, 15): The expected type comes from the return type of this signature.

  • @inadogsworld
    @inadogsworld Жыл бұрын

    I need help creating a custom map for my business and I know a website that I want to mimic... Could you please teach me how to this virtually on zoom? Also, what do you charge to teach me?

  • @gigakvachakhia4777
    @gigakvachakhia47772 жыл бұрын

    it propmted me with open your billing account issue. and map is on development mode with watermarks. this aint free anymore?

  • @shreyanshgajipara
    @shreyanshgajipara Жыл бұрын

    project a lot because I've been working on other stuff (and being lazy lol). Also, I had been facing a recurring problem of content dropouts in

  • @antoparjiyo2785
    @antoparjiyo2785 Жыл бұрын

    2 years passed damn

  • @instinct_gallant8694
    @instinct_gallant8694 Жыл бұрын

    There's a video on In The setup's channel about free DAWs, alternatives, and even if you can't afford it you can "get" it. Not quite an

  • @ertemeren
    @ertemeren3 ай бұрын

    I'm trying to send coordinates to back-end...

  • @jerrytab4276
    @jerrytab4276 Жыл бұрын

    How to get all nearest houses in your office within 1.5km?

  • @EmanualJade
    @EmanualJade Жыл бұрын

    If is not working for you due to a type error. Try this {clusterer => ( {houses.map(house => ( ))} )}

  • @kacperm8450

    @kacperm8450

    Жыл бұрын

    I tried. The type error is gone then. But i can't see any markers. Any advice ?

  • @Luke-fo9bo

    @Luke-fo9bo

    9 ай бұрын

    I have this issue, did you figure it out?@@kacperm8450

  • @user-ub5nv1eo9k

    @user-ub5nv1eo9k

    7 ай бұрын

    Thank you!

  • @AlexA-hx7du
    @AlexA-hx7du9 ай бұрын

    It useless to .env the variables for client side rendering components? since this .env variables will be used on client browser and can be seen. The code you've provided is not safe if the process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY contains a sensitive API key because this key is exposed directly in the client-side code.

  • @ahmedfarhat8853
    @ahmedfarhat8853 Жыл бұрын

    You should be my maths teacher

  • @vuongqtvn
    @vuongqtvn2 жыл бұрын

    😍