Skip to content

Commit 14ddf46

Browse files
Merge pull request #103 from Chia-Chi-Shen/storybook
Correct typos and add contents to README
2 parents 392bd36 + 81a7290 commit 14ddf46

File tree

19 files changed

+139
-92
lines changed

19 files changed

+139
-92
lines changed

README.md

+54-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,55 @@
1-
## React Azure Maps Storybook
1+
# React Azure Maps Playground
22

3-
The React Azure Map Storybook provides a hands-on way to explore and interact with **react-azure-maps**. <br/>
4-
With Storybook, You can try adjusting various settings and see how these components work in real-time. <br/>
5-
This helps you understand the practical applications of the package and how to integrate Azure Maps into your React projects effectively.
3+
The **React Azure Map Playground** utilize [Storybook](https://storybook.js.org/) to provide an interactive way to explore and experiment with the [**react-azure-maps**](https://github.com/Azure/react-azure-maps) components.<br/>
4+
Visit React Azure Map Playground: https://azure.github.io/react-azure-maps-playground/
5+
6+
## Usage
7+
8+
In the playground, you can:
9+
10+
- Learn how to effectively integrate Azure Maps into your React projects
11+
- Adjust the component settings via the controls provided.
12+
- Observe the immediate effects of your changes on the map.
13+
- Read the full source code of the examples.
14+
15+
## Running Locally
16+
17+
Before you begin, ensure you have met the following requirements:
18+
19+
- **Node.js**: Make sure you have Node.js installed on your machine. This project uses Node.js v20.16.0.
20+
- **npm**: npm is required for package management. It comes with Node.js, so you should have it by default.
21+
22+
### Installation
23+
24+
Follow these steps to get your local environment up and running:
25+
26+
1. **Clone the Repository**
27+
28+
```bash
29+
git clone https://github.com/Azure/react-azure-maps-playground.git
30+
```
31+
32+
2. **Navigate to the Project Directory**
33+
34+
```bash
35+
cd react-azure-maps-playground
36+
```
37+
38+
3. **Install Dependencies**
39+
40+
Use npm to install the necessary packages:
41+
42+
```bash
43+
npm install
44+
```
45+
46+
### Running the Project
47+
48+
Once the dependencies are installed, you can run the project locally.<br/>
49+
Start the Storybook server to view and interact with the components:
50+
51+
```bash
52+
npm run storybook
53+
```
54+
55+
Open your web browser and navigate to [http://localhost:6006](http://localhost:6006) to view the Storybook interface.

src/stories/BasicUsage/MapControls/MapControl.mdx

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ import MapControl, { controls } from './MapControl';
44

55
<Meta title="Basic Usage/Map Control" />
66

7-
# MapControl
7+
# Map Control
88
These examples show all the map navigation controls on the map and how to customize different option settings.
99

10-
## Style control
10+
## Style Control
1111

1212

1313
<MapControl controls={[controls[0]]}/>
@@ -32,7 +32,7 @@ import {
3232
</AzureMapsProvider>;
3333
`}/>
3434

35-
## Zoom control
35+
## Zoom Control
3636

3737
<MapControl controls={[controls[1]]}/>
3838
<Source code={`
@@ -55,7 +55,7 @@ import {
5555
</AzureMapsProvider>;
5656
`}/>
5757

58-
## Compass control
58+
## Compass Control
5959

6060
<MapControl controls={[controls[2]]}/>
6161
<Source code={`
@@ -79,7 +79,7 @@ import {
7979
</AzureMapsProvider>;
8080
`}/>
8181

82-
## Pitch control
82+
## Pitch Control
8383

8484
<MapControl controls={[controls[3]]}/>
8585
<Source code={`
@@ -103,7 +103,7 @@ import {
103103
</AzureMapsProvider>;
104104
`}/>
105105

106-
## Traffic control and Legend control
106+
## Traffic Control and Legend Control
107107

108108
<MapControl controls={[controls[4], controls[5]]}/>
109109
<Source code={`

src/stories/BasicUsage/MapRef/MapRef.mdx

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const YourComponent = () => {
1818
1919
useEffect(() => {
2020
if (isMapReady && mapRef)
21-
// do something with mapRef
21+
// Do something with mapRef
2222
}, [isMapReady]);
2323
2424
return (
@@ -27,7 +27,7 @@ const YourComponent = () => {
2727
}
2828
`}/>
2929

30-
Remember to wrap your component with AzureMapsProvider to provide the necessary context:
30+
Remember to wrap your component with AzureMapsProvider to provide the necessary context.
3131

3232
<Source code={`
3333
import { AzureMapsProvider } from 'react-azure-maps';
@@ -44,7 +44,7 @@ const NewComponent = () => {
4444

4545
## Examples
4646
Here are two examples of how to use the `mapRef` to change the map's display. <br/>
47-
Only codes refering to the usage of `mapRef` are shown here. Don't forget to wrap your component with `AzureMapsProvider` when implementing the examples!
47+
Only codes referring to the usage of `mapRef` are shown here. Don't forget to wrap your component with `AzureMapsProvider` when implementing the examples!
4848

4949
In the first example, we use the `setCamera()` function to change the center of the map. <br/>
5050
Click the button to see the effect.
@@ -64,7 +64,7 @@ const SetCenter = () => {
6464
// Set the map center when the map is ready or when the map center changes.
6565
useEffect(() => {
6666
if (isMapReady && mapRef)
67-
// set map center
67+
// Set map center
6868
mapRef.setCamera({ center: mapCenter });
6969
}, [isMapReady, mapCenter]);
7070
@@ -107,7 +107,7 @@ const SetStyle = () => {
107107
//Set the tile boundaries when the map is ready or when the showTileBoundaries state changes
108108
useEffect(() => {
109109
if (isMapReady && mapRef)
110-
// toggle tile boundaries
110+
// Toggle tile boundaries
111111
mapRef.setStyle({ showTileBoundaries });
112112
}, [isMapReady, showTileBoundaries]);
113113

src/stories/BasicUsage/MapStyles/MapStyles.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ You can change the style of the map by passing the `styleOptions` prop like this
99
<Source code={`
1010
import { AzureMap, AzureMapsProvider } from 'react-azure-maps';
1111
12-
const Your_Component = () => {
12+
const YourComponent = () => {
1313
return (
1414
<AzureMapsProvider>
1515
<AzureMap

src/stories/DataVisualization/BubbleLayer/BubbleLayer.mdx

+10-10
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ For more available properties, see the documentation [BubbleLayerOptions](https:
1616

1717
<Source code={`
1818
<AzureMapLayerProvider
19-
type="BubbleLayer"
20-
options={{
21-
radius: 10,
22-
color: 'DodgerBlue',
23-
opacity: 1,
24-
strokeColor: 'DarkBlue',
25-
strokeWidth: 2,
26-
strokeOpacity: 1,
27-
blur: 0,
28-
}}
19+
type="BubbleLayer"
20+
options={{
21+
radius: 10,
22+
color: 'DodgerBlue',
23+
opacity: 1,
24+
strokeColor: 'DarkBlue',
25+
strokeWidth: 2,
26+
strokeOpacity: 1,
27+
blur: 0,
28+
}}
2929
/>
3030
`} />

src/stories/DataVisualization/ClusterAggregates/ClusterAggregate.mdx

+6-6
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import ClusterAggregates from './ClusterAggregates';
55
<Meta title="Data Visualization/Cluster Aggregates"/>
66

77
# Cluster Aggregates
8-
This example shows how to enable point based clustering on a data source and render them differently from individual points on the map.
9-
Clustered points have four properties;
8+
This example shows how to enable point-based clustering on a data source and render them differently from individual points on the map.
9+
Clustered points have four properties:
1010
- `cluster` - A boolean value indicating that it is a cluster.
11-
- `cluster_id` - A unique id for the cluster which can be used with the DataSource getClusterExpansionZoom, getClusterChildren, and getClusterLeaves functions.
11+
- `cluster_id` - A unique ID for the cluster which can be used with the DataSource getClusterExpansionZoom, getClusterChildren, and getClusterLeaves functions.
1212
- `point_count` - The number of points the cluster contains.
1313
- `point_count_abbreviated` - A string that abbreviates the point_count value if it is long. (i.e. 4,000 becomes 4K)
1414

@@ -34,7 +34,7 @@ const bubbleLayerOptions = {
3434
40, //If point_count >= 750, radius is 40 pixels.
3535
],
3636
37-
//Change the color of the cluster based on the value on the point_cluster property of the cluster.
37+
//Change the color of the cluster based on the value of the point_cluster property of the cluster.
3838
color: [
3939
'step',
4040
['get', 'point_count'],
@@ -45,7 +45,7 @@ const bubbleLayerOptions = {
4545
'rgba(255,0,0,0.8)', //If the point_count >= 100, color is red.
4646
],
4747
strokeWidth: 0,
48-
filter: ['has', 'point_count'], //Only rendered data points which have a point_count property, which clusters do.
48+
filter: ['has', 'point_count'], //Only render data points which have a point_count property, which clusters do.
4949
};
5050
`}/>
5151

@@ -86,7 +86,7 @@ const ClusterAggregates = () => {
8686
cluster: true,
8787
//The radius in pixels to cluster points together.
8888
clusterRadius: 45,
89-
//The maximium zoom level in which clustering occurs.
89+
//The maximium zoom level at which clustering occurs.
9090
//If you zoom in more than this, all points are rendered as symbols.
9191
clusterMaxZoom: 15,
9292
}}

src/stories/DataVisualization/Datavisualization.mdx

+15-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Meta, Source } from '@storybook/blocks';
2-
import ClusterAggregates from './ClusterAggregates/ClusterAggregates'
2+
import ClusterAggregates from './ClusterAggregates/ClusterAggregates';
33

44
<Meta title="Data Visualization/Introduction"/>
55

@@ -8,31 +8,26 @@ import ClusterAggregates from './ClusterAggregates/ClusterAggregates'
88

99
<ClusterAggregates showBubbles showNumbers/>
1010

11-
We will need 2 kinds of components to visualize data on a map:
12-
1. `<AzureMapDataSourceProvider>` : to provide your data to the map.
13-
2. `<AzureMapLayerProvider>` : to create a visualization layer on the map based on your data.
11+
We will need two kinds of components to visualize data on a map:
12+
1. `<AzureMapDataSourceProvider>`: to provide your data to the map.
13+
2. `<AzureMapLayerProvider>`: to create a visualization layer on the map based on your data.
1414

1515
Therefore, the basic structure of a data visualization component is as follows:
1616

1717
<Source code= {`
1818
import { AzureMap, AzureMapsProvider, AzureMapDataSourceProvider, AzureMapLayerProvider } from 'react-azure-maps';
1919
2020
const Your_Component = () => {
21-
return (
22-
<AzureMapsProvider>
23-
<AzureMap options={your_options}>
24-
<AzureMapDataSourceProvider
25-
id="your_layer_id"
26-
collection={your_data}>
27-
<AzureMapLayerProvider
28-
type="layer_type"
29-
options={your_layer_options}
30-
/>
31-
</AzureMapDataSourceProvider>
32-
</AzureMap>
33-
</AzureMapsProvider>
34-
)
35-
}
21+
return (
22+
<AzureMapsProvider>
23+
<AzureMap options={your_options}>
24+
<AzureMapDataSourceProvider id="your_layer_id" collection={your_data}>
25+
<AzureMapLayerProvider type="layer_type" options={your_layer_options} />
26+
</AzureMapDataSourceProvider>
27+
</AzureMap>
28+
</AzureMapsProvider>
29+
);
30+
};
3631
`} />
3732
## Create a data source
3833
To create a data source, you can pass the data to the `collection` prop in various ways: <br/>
@@ -70,4 +65,4 @@ You can also provide the data by passing the `dataFromUrl` prop like this: <br/>
7065

7166
<br/>
7267
Now that you have created a data source, you can create a visualization layer on the map. <br/>
73-
See expamples below for further details.
68+
See examples below for further details.

src/stories/DataVisualization/HeatMapLayer/HeatMapLayer.mdx

+9-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import HeatMapLayer from './HeatMapLayer';
77
# Heat Map Layer
88

99
A heat map layer can be used to visualize the density of point data on the map.<br/>
10-
Following code shows how to add a simple heat map layer. A thorough tutorial can be found [here](https://learn.microsoft.com/en-us/azure/azure-maps/map-add-heat-map-layer).<br/>
10+
The following code shows how to add a simple heat map layer. A thorough tutorial can be found [here](https://learn.microsoft.com/en-us/azure/azure-maps/map-add-heat-map-layer).<br/>
1111
For more available properties, see the documentation [HeatMapLayerOptions](https://learn.microsoft.com/en-us/javascript/api/azure-maps-control/atlas.heatmaplayeroptions?view=azure-maps-typescript-latest).
1212

1313
<HeatMapLayer radius={10}/>
@@ -16,14 +16,14 @@ For more available properties, see the documentation [HeatMapLayerOptions](https
1616
<AzureMapLayerProvider
1717
type="HeatLayer"
1818
options={{
19-
radius={10},
20-
opacity={1},
21-
intensity={1},
19+
radius: 10,
20+
opacity: 1,
21+
intensity: 1,
2222
}}
2323
/>
2424
`}/>
2525

26-
## color
26+
## Color
2727
You can customize the color of the heat map layer by passing the `color` prop like this: <br/>
2828

2929
<HeatMapLayer
@@ -60,10 +60,10 @@ You can customize the color of the heat map layer by passing the `color` prop li
6060
/>
6161
`}/>
6262

63-
## weight
63+
## Weight
6464
Specifies how much an individual data point contributes to the heatmap. <br/>
65-
Must be a number greater than 0. Default `1`.<br/>
66-
In our example, we set the weight based on "mag" property of the earthquake data. <br/>
65+
Must be a number greater than 0. Default is `1`.<br/>
66+
In our example, we set the weight based on the "mag" property of the earthquake data. <br/>
6767

6868
<HeatMapLayer
6969
radius={10}
@@ -91,7 +91,7 @@ In our example, we set the weight based on "mag" property of the earthquake data
9191
10,
9292
1,
9393
]}
94-
/>;
94+
/>
9595
`}/>
9696

9797

src/stories/DataVisualization/ImageLayer/ImageLayer.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ import ImageLayer from './ImageLayer';
66

77
# Image Layer
88

9-
You can overlay an image to a fixed set of coordinates with the Image Layer.<br/>
10-
Following code shows how to add a simple image layer. A thorough tutorial can be found [here](https://learn.microsoft.com/en-us/azure/azure-maps/map-add-image-layer).<br/>
9+
You can overlay an image on a fixed set of coordinates with the Image Layer.<br/>
10+
The following code shows how to add a simple image layer. A thorough tutorial can be found [here](https://learn.microsoft.com/en-us/azure/azure-maps/map-add-image-layer).<br/>
1111
For more available properties, see the documentation [ImageLayerOptions](https://learn.microsoft.com/en-us/javascript/api/azure-maps-control/atlas.imagelayeroptions?view=azure-maps-typescript-latest).
1212

13-
> Note that browsers might have difficulty loading a large image. In this case, consider breaking your image up into tiles, and loading them into the map as a [TileLayer](/docs/data-visualization-tile-layer--docs).
13+
> Note that browsers might have difficulty loading a large image. In this case, consider breaking your image up into tiles and loading them into the map as a [TileLayer](/docs/data-visualization-tile-layer--docs).
1414
1515
<ImageLayer/>
1616

src/stories/DataVisualization/LineLayer/LineLayer.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import LineLayer from './LineLayer';
88

99
A line layer can be used to render LineString and MultiLineString features as paths or routes on the map.<br/>
1010
It can also be used to render the outline of Polygon and MultiPolygon features.<br/><br/>
11-
Following code shows how to add a simple line layer. A thorough tutorial can be found [here](https://learn.microsoft.com/en-us/azure/azure-maps/map-add-line-layer)<br/>
12-
For more available properties, see the documentation [LineLayerOptions](https://learn.microsoft.com/en-us/javascript/api/azure-maps-control/atlas.linelayeroptions?view=azure-maps-typescript-latest)
11+
The following code shows how to add a simple line layer. A thorough tutorial can be found [here](https://learn.microsoft.com/en-us/azure/azure-maps/map-add-line-layer).<br/>
12+
For more available properties, see the documentation [LineLayerOptions](https://learn.microsoft.com/en-us/javascript/api/azure-maps-control/atlas.linelayeroptions?view=azure-maps-typescript-latest).
1313

1414
<LineLayer/>
1515

src/stories/DataVisualization/PolygonExtrusion/PolygonExtrusion.mdx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import * as PolygonExtrusionStories from './PolygonExtrusion.stories';
88

99
# Polygon Extrusion
1010

11-
The polygon extrusion layer renders the areas of a **Polygon** and **MultiPolygon** features as extruded shapes.<br/>
12-
The height and base properties of the polygon extrusion layer define the base distance from the ground and height of the extruded shape in meters.
11+
The polygon extrusion layer renders the areas of **Polygon** and **MultiPolygon** features as extruded shapes.<br/>
12+
The height and base properties of the polygon extrusion layer define the base distance from the ground and the height of the extruded shape in meters.
1313

1414
<PolygonExtrusion height={30}/>
1515

src/stories/DataVisualization/PolygonLayer/PolygonLayer.mdx

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import * as PolygonLayerStories from './PolygonLayer.stories';
44

55
<Meta of={PolygonLayerStories}/>
66

7-
# PolygonLayer
7+
# Polygon Layer
88

9-
To create a polygon, add it to a data source, and render it with a polygon layer using the PolygonLayer class.
9+
To create a polygon, add it to a data source and render it with a polygon layer using the PolygonLayer class.
1010

1111
<PolygonLayer fillOpacity={0.5} fillColor={'black'}/>
12-
<Source code={`<AzureMapLayerProvider type="PolygonLayer" options={{ fillColor: 'black', fillOpacity: 0.5 }} />;
12+
<Source code={`
13+
<AzureMapLayerProvider type="PolygonLayer" options={{ fillColor: 'black', fillOpacity: 0.5 }} />
1314
`}/>

0 commit comments

Comments
 (0)