To use Mapbox services, you'll need to create an account and generate an API key. Follow these steps to get your API key:
- Visit the Mapbox website.
- Click on the Sign Up button located at the top right corner of the page.
- Fill in the registration form with your details:
- Email Address
- Username
- Password
- Agree to the terms of service and privacy policy.
- Click on the Sign Up button to create your account.
- After signing up, you will receive a confirmation email from Mapbox.
- Open the email and click on the verification link to confirm your email address.
- Once your email is verified, go back to the Mapbox website.
- Click on the Log In button at the top right corner of the page.
- Enter your email and password, then click Log In.
- After logging in, you will be redirected to your account dashboard.
- In the dashboard, navigate to the Account section from the sidebar menu.
- In the Account section, look for the API access tokens panel.
- Click on the Create a token button.
- Give your token a name for easy identification (e.g., "My First API Key").
- Optionally, you can define the scopes and restrictions for your token based on your requirements.
- Click on the Create token button to generate your API key.
- Your new API key will be displayed on the screen.
- Copy the API key and save it in a secure place.
- Create a
.env
in the root of the repository. - Paste
VITE_MAPBOX_ACCESS_TOKEN = <YOUR_API_KEY>
to.env
Deploying an application to Heroku involves several steps, including setting up a Heroku account, installing the Heroku CLI, preparing your application, and finally deploying it. Here’s a step-by-step guide:
- A Heroku account. If you don't have one, sign up at Heroku.
- Heroku CLI installed on your local machine.
Open your terminal and log in to Heroku using the CLI:
heroku login
A web browser will open, prompting you to log in to your Heroku account.
Navigate to your project directory and create a new Heroku app:
cd /path/to/your/project
heroku apps:create <your-app-name>
This command will create a new Heroku app and link it to your project. You will see a URL for your new Heroku app. You might need to visit the link if failed to create and fill in your payment method.
heroku buildpacks:add heroku-community/nginx -a <your-app-name>
git push heroku main
Heroku will build and deploy your application. You can see the progress in the terminal.
Once the deployment is complete, you can open your application in the browser:
heroku open
If your application requires environment variables, you can set them using the Heroku CLI. For example:
heroku config:set VITE_MAPBOX_ACCESS_TOKEN=<your-mapbox-api-key>