-
Notifications
You must be signed in to change notification settings - Fork 63
Add React setup instructions to documentation #346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AdarshSahani003
wants to merge
2
commits into
stadiamaps:main
Choose a base branch
from
AdarshSahani003:add-react-setup
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,7 +3,7 @@ | |
| This section of the guide covers how to integrate Ferrostar into a web app. | ||
| While there are limitations to the web [Geolocation API](https://developer.mozilla.org/en-US/docs/Web/API/Geolocation_API) | ||
| (notably no background updates), | ||
| PWAs and other mobile-optimized sites | ||
| **Progressive Web Apps (PWAs)** and other mobile-optimized sites | ||
| can be a great solution when a native iOS/Android app is impractical or prohibitively expensive. | ||
|
|
||
| We'll cover the "batteries included" approach, but flag areas for customization and overrides along the way. | ||
|
|
@@ -33,7 +33,7 @@ Then add `wasm()` and `topLevelAwait()` to the `plugins` section of your Vite co | |
|
|
||
| TODO | ||
|
|
||
| ## Add Ferrostar web components to your web app | ||
| ## Add Ferrostar web components to your Web App | ||
|
|
||
| The Ferrostar web SDK uses the [Web Components](https://developer.mozilla.org/en-US/docs/Web/API/Web_components) | ||
| to ensure maximum compatibility across frontend frameworks. | ||
|
|
@@ -43,35 +43,57 @@ You can import the components just like other things you’re used to in JavaScr | |
| import { FerrostarMap, BrowserLocationProvider } from "@stadiamaps/ferrostar-components"; | ||
| ``` | ||
|
|
||
| ## Configure the `<ferrostar-map>` component | ||
| ## Configure the <ferrostar-map> Component | ||
|
|
||
| Now you can use Ferrostar in your HTML like this: | ||
| Now you can use Ferrostar in your web component like this: | ||
|
|
||
| ```html | ||
| ## HTML | ||
|
|
||
| ``` | ||
| <ferrostar-map | ||
| id="ferrostar" | ||
| id="ferrostar" | ||
| valhallaEndpointUrl="https://api.stadiamaps.com/route/v1" | ||
| styleUrl="https://tiles.stadiamaps.com/styles/outdoors.json" | ||
| profile="bicycle" | ||
| ></ferrostar-map> | ||
| ``` | ||
|
|
||
| Here we have used Stadia Maps URLs, which should work without authentication for local development. | ||
| (Refer to the [authentication docs](https://docs.stadiamaps.com/authentication/) | ||
| for network deployment details; you can start with a free account.) | ||
| ## React | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that the first example should remain generic, and we should have separate sections for framework-specific (React, Vue, etc.) code. This appears to replace the generic code, which is applicable to a large number of users, with a React-specific example. |
||
|
|
||
| ```javascript | ||
| import React from 'react'; | ||
| import { FerrostarMap } from "@stadiamaps/ferrostar-webcomponents"; | ||
|
|
||
| const MyMapComponent = () => { | ||
| return ( | ||
| <ferrostar-map | ||
| id="ferrostar" | ||
| valhallaEndpointUrl="https://api.stadiamaps.com/route/v1" | ||
| styleUrl="https://tiles.stadiamaps.com/styles/outdoors.json" | ||
| profile="bicycle" | ||
| style={{ display: 'block', width: '100%', height: '100%' }} ></ferrostar-map> | ||
| ); | ||
| }; | ||
|
|
||
| export default MyMapComponent; | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| See the [vendors appendix](./vendors.md) for a list of other compatible vendors. | ||
| ## CSS Requirements | ||
|
|
||
| `<ferrostar-map>` additionally requires setting some CSS manually, or it will be invisible! | ||
| The `<ferrostar-map>` component requires setting some CSS manually; otherwise, it will be invisible! | ||
|
|
||
| ```css | ||
| ferrostar-map { | ||
| display: block; | ||
| width: 100%; | ||
| height: 100%; | ||
| display: block; | ||
| width: 100%; | ||
| height: 100%; | ||
| } | ||
| ``` | ||
|
|
||
| --- | ||
|
|
||
| That’s all you need to get started! | ||
|
|
||
| ### Configuration explained | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.