Sign Up

Talk Programming , Career, Mental Health, Talk Personal Finance ❤️‍ Post a query and receive responses ✅

Have an account? Sign In


Have an account? Sign In Now

Sign In

Post a query and receive responses. Ask anything, Ask Mitra ❤️‍

Sign Up Here


Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.


Have an account? Sign In Now

Sorry, you do not have permission to ask a question, You must login to ask a question.


Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

Ask Mitra

Ask Mitra Logo Ask Mitra Logo

Ask Mitra Navigation

  • Home
  • About Us
  • Find Jobs
  • Blogs
    • Add New Blog !
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Ask a Question
  • Home
  • All Categories
  • Find Jobs
  • Points and Swags
    • Badges and Points
    • Ask Mitra Swags
  • Blog
    • Add New Blog !
  • FAQs
  • Community Members 💓
  • About Us
  • Contact Us
Home| Questions|Q 85614
Next
In Process
Aryan Pariyar
Aryan PariyarSensei
Asked: December 6, 20222022-12-06T18:32:56+05:45 2022-12-06T18:32:56+05:45In: Web Development

How to implement mapbox in nextjs in latest version of react-map-gl

Hello mitro’s

I am working on one of the web app there i want to show map on it. How can i show it on my site I have done some work by seeing docs but its not working in my project

MyCode:

import Map from ‘react-map-gl’;
function Mapp() {
  return
    <Map
    initialViewState={{
      longitude: -100,
      latitude: 40,
      zoom: 3.5
    }}
    style={{width: 600, height: 400}}
    mapStyle=’mapbox://styles/aryanpariyar/clbbzjybs000014muujyl5q6h’
    mapboxAccessToken={process.env.mapboxAccessToken}
    />;
    }
export default Mapp;
but its not fetching the data from the site.
here is the docs
mapboxreactreact-map-gl
  • 0
  • 1 1 Answer
  • 43 Views
  • 0 Followers
  • 0
Share
  • Facebook

    Related Questions

    • Can anyone provide me a react learning resource: mega link or torrent link?
    • How to Upload Multiple Images in Django App from React Frontend?
    • React Programming
    • Best Institute for learning React.JS (Front End Development) ?
    • Cannot use API on development

    You must login to add an answer.


    Forgot Password?

    Need An Account, Sign Up Here

    1 Answer

    • Voted
    • Oldest
    • Recent
    • Random
    1. THE BIG OCEAN Explainer
      2022-12-20T19:39:44+05:45Added an answer on December 20, 2022 at 7:39 pm

      To implement Mapbox in a Next.js app using the latest version of react-map-gl, you will need to do the following:

      1. Install react-map-gl: Run npm install react-map-gl or yarn add react-map-gl to install the react-map-gl library in your Next.js app.
      2. Get a Mapbox access token: Go to the Mapbox website and sign up for an account to get a Mapbox access token.
      3. Add the Mapbox CSS file to your Next.js app: Add the following line to the head element of your Next.js app’s _app.js file to include the Mapbox CSS file:
      Copy code
      <link href='https://api.mapbox.com/mapbox-gl-js/v1.12.0/mapbox-gl.css' rel='stylesheet' />
      1. Import react-map-gl and use the Map component: In the component where you want to display the map, import react-map-gl and use the Map component. Pass your Mapbox access token as a prop to the Map component, and set the style prop to the style URL for the Mapbox style you want to use.

      For example:

      Copy code
      import MapGL from 'react-map-gl';

      const MyMap = () => {
      return (
      <MapGL
      width={400}
      height={400}
      mapboxApiAccessToken={'YOUR_MAPBOX_ACCESS_TOKEN'}
      style={"mapbox://styles/mapbox/streets-v11"}
      />

      );
      };

      1. Customize the map: You can customize the map by adding additional props to the Map component, such as latitude, longitude, and zoom to set the initial view of the map, or onViewportChange to handle viewport changes. You can also add other Mapbox components, such as Marker or Popup, to add features to the map.

      For more information and examples, you can refer to the react-map-gl documentation.

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp

    Sidebar

    Ask A Question

    Your Favourite Topics

    • Announcements
    • Blockchain
    • Books

        • —Non Tech Books
        • —technical books
    • Business and Entrepreneurship
    • Careers
    • College
    • Content and Blog
    • CyberSecurity
    • Design and Arts
    • Devices and Gadgets
    • Digital Marketing
    • Entertainment

        • —Movies-Series-TV
        • —Music
        • —Sports
    • Events
    • For Admins only.
    • Health

        • —Fitness
    • Money

        • —Personal Finance
        • —Stock Market
    • Operating System

        • —linux
        • —windows
    • Other
    • Paid Internship
    • Programming

        • —AI/ML
        • —APIs
        • —C & C#
        • —Django
        • —Flutter
        • —Go
        • —HTML&CSS
        • —Java
        • —JavaScript
        • —Mobile Apps Development
        • —Node Js
        • —NoSQL
        • —Php
        • —Python
        • —React JS
        • —SQL

    Stats

    • Questions 1k
    • Answers 10k
    • Best Answers 391
    • Users 2k

    Top 6 Members This Month

    Vicky

    Vicky

    • 0 Questions
    • 78 Points
    Sensei
    puppet

    puppet

    • 0 Questions
    • 23 Points
    Beginner
    wtfixair

    wtfixair

    • 0 Questions
    • 22 Points
    Beginner
    Dhanmaya

    Dhanmaya

    • 0 Questions
    • 20 Points
    Beginner
    Riyesh

    Riyesh

    • 0 Questions
    • 20 Points
    Beginner
    pranitkarki

    pranitkarki

    • 0 Questions
    • 20 Points
    Beginner

    Trending Tags

    askmitra blockchain c++ career coding College cybersecurity Django Flutter help javascript laptop laravel linux poll Programming python question react web web development wordpress
    • Popular
    • Answers
    • Rounak Agrawal

      Ask Mitra Udemy Courses Giveaway

      • 76 Answers
    • Subedi Bibek

      The Complete JavaScript Course 2022: From Zero to Expert! Udemy ...

      • 73 Answers
    • Subedi Bibek

      Mega Giveaway at askmitra.com 🔥

      • 69 Answers
    • bishwaKiran
      bishwaKiran added an answer Try getting into githubs student program, use your university/collage/school ID… January 30, 2023 at 7:44 pm
    • Sandeep Poudel
      Sandeep Poudel added an answer SOLVED: It was due to unfinished SSL certificate installation January 27, 2023 at 7:11 pm
    • Aashutosh_k
      Aashutosh_k added an answer Software piracy protection system Fingerprint voting system Stock price prediction… January 26, 2023 at 7:37 pm

    Related Questions

    • How to check if the bat/ball touches the 4 sides ...

      • 2 Answers
    • Input Direction confusion in snake game JavaScript?

      • 1 Answer
    • which tech jobs have higest demand but least supply in ...

      • 1 Answer
    • What does ReactJS intern do in a internship programme?

      • 2 Answers
    • How to make stock market website?

      • 2 Answers

    Explore

    • Home
    • Trending Category
      • Programming
      • Web Development
      • —Mobile Apps Development
      • —Stock Market
      • Business and Entrepreneurship
      • Blockchain
      • College
      • —Personal Finance
      • —HTML&CSS
      • —JavaScript
      • —Python
      • —React JS
      • —Node Js
      • —C & C#
      • Content and Blog
      • Careers
    • All Categories
      • Go to All Categories
      • Health
      • —Go
      • —Flutter
      • Digital Marketing
      • —APIs
      • Devices and Gadgets
    • Find Job and Internships
    • Points and Swags
      • Badges and Points
      • Ask Mitra Swags
    • All Blogs
      • Add New Blog !
    • FAQs
    • Community Members 💓
    • Questions
      • Un Answered
      • New Questions
      • Most Seen Questions
      • Most Answered
      • Trending Questions
    • Tags

    Footer

    Ask Mitra

    Ask Mitra

    Ask Mitra is a social question and answer engine that will assist you in forming a community and connecting with others. Talk about programming, your career, your mental health, and your personal finances. ❤️‍ Post a query and receive responses ✅

    Quick Navigation

    • Ask a Question
    • Home
    • All Categories
    • Find Jobs
    • Points and Swags
      • Badges and Points
      • Ask Mitra Swags
    • Blog
      • Add New Blog !
    • FAQs
    • Community Members 💓
    • About Us
    • Contact Us

    Legal Stuff

    • Terms of use and policy