Skip to content

Commit c2a9ade

Browse files
author
Savina Shen (Manpower Services Taiwan Co Ltd)
committed
add symbol and polygon layer
1 parent b11e6d7 commit c2a9ade

File tree

14 files changed

+669
-47
lines changed

14 files changed

+669
-47
lines changed

package-lock.json

Lines changed: 254 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"azure-maps-control": "^3.0.1",
6+
"azure-maps-control": "^3.3.0",
77
"react": "^18.2.0",
88
"react-azure-maps": "^1.0.0",
99
"react-dom": "^18.2.0",

src/Storybook.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
width: 700px;
33
height: 300px;
44
}
5+
6+
.atlas-map .azure-map-copyright a {
7+
font-size: 9px;
8+
}

src/stories/DataVisualization/BubbleLayer/BubbleLayer.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ For more available properties, see the documentation [BubbleLayerOptions](https:
1919
{/* <Canvas of={BubbleLayerStories.Example} sourceState="none" /> */}
2020

2121
<Source code={`
22-
import { AzureMapLayerProvider } from 'react-azure-maps';
23-
2422
<AzureMapLayerProvider
2523
type="BubbleLayer"
2624
options={{

src/stories/DataVisualization/Datavisualization.mdx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,22 @@ Therefore, the basic structure of a data visualization component is as follows:
1818
<Source code= {`
1919
import { AzureMap, AzureMapsProvider, AzureMapDataSourceProvider, AzureMapLayerProvider } from 'react-azure-maps';
2020
21-
<AzureMapsProvider>
22-
<AzureMap options={your_options}>
23-
<AzureMapDataSourceProvider
24-
id="your_layer_id"
25-
collection={your_data}>
26-
<AzureMapLayerProvider
27-
type="layer_type"
28-
options={your_layer_options}
29-
/>
30-
</AzureMapDataSourceProvider>
31-
</AzureMap>
32-
</AzureMapsProvider>
21+
const Your_Component = () => {
22+
return (
23+
<AzureMapsProvider>
24+
<AzureMap options={your_options}>
25+
<AzureMapDataSourceProvider
26+
id="your_layer_id"
27+
collection={your_data}>
28+
<AzureMapLayerProvider
29+
type="layer_type"
30+
options={your_layer_options}
31+
/>
32+
</AzureMapDataSourceProvider>
33+
</AzureMap>
34+
</AzureMapsProvider>
35+
)
36+
}
3337
`} />
3438
## Create a data source
3539
To create a data source, you can pass the data to the `collection` prop in various ways: <br/>

src/stories/DataVisualization/HeatMapLayer/HeatMapLayer.mdx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ Following code shows how to add a simple heat map layer:<br/>
1212
<HeatMapLayer radius={10}/>
1313

1414
<Source code={`
15-
import { AzureMapLayerProvider } from 'react-azure-maps';
16-
1715
<AzureMapLayerProvider
1816
type="HeatLayer"
1917
options={{
@@ -42,8 +40,6 @@ You can customize the color of the heat map layer by passing the `color` prop li
4240
]}/>
4341

4442
<Source code={`
45-
import { AzureMapLayerProvider } from 'react-azure-maps';
46-
4743
<AzureMapLayerProvider
4844
type="HeatLayer"
4945
options={{
@@ -82,8 +78,6 @@ In our example, we set the weight based on "mag" property of the earthquake data
8278
/>
8379

8480
<Source code={`
85-
import { AzureMapLayerProvider } from 'react-azure-maps';
86-
8781
<AzureMapLayerProvider
8882
type="HeatLayer"
8983
options={{

src/stories/DataVisualization/LineLayer/LineLayer.mdx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ For more available properties, see the documentation [LineLayerOptions](https://
1414
<LineLayer/>
1515

1616
<Source code={`
17-
import { AzureMapLayerProvider } from 'react-azure-maps';
18-
1917
<AzureMapLayerProvider
2018
type="LineLayer"
2119
options={{

src/stories/DataVisualization/LineLayer/LineLayer.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,4 @@ const LineLayer = ({ strokeColor, strokeWidth, strokeOpacity, blur, lineCap, tra
3434
);
3535
};
3636

37-
function generateRandomPoints() {
38-
var layerData = [];
39-
40-
for (var i = 0; i < 50; i++) {
41-
layerData.push(
42-
new atlas.data.Feature(new atlas.data.Point([Math.random() * 360 - 180, Math.random() * 170 - 85]), {
43-
title: 'Pin_' + i,
44-
}),
45-
);
46-
}
47-
48-
return layerData;
49-
}
50-
5137
export default LineLayer;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import PolygonLayer from './PolygonLayer';
2+
import { Source, Meta } from '@storybook/addon-docs/blocks';
3+
import * as PolygonLayerStories from './PolygonLayer.stories';
4+
5+
<Meta of={PolygonLayerStories}/>
6+
7+
# PolygonLayer
8+
9+
To create a polygon, add it to a data source, and render it with a polygon layer using the PolygonLayer class.
10+
11+
<PolygonLayer fillOpacity={0.5} fillColor={'black'}/>
12+
<Source code={`<AzureMapLayerProvider type="PolygonLayer" options={{ fillColor: 'black', fillOpacity: 0.5 }} />;
13+
`}/>
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import type { Meta, StoryObj } from '@storybook/react';
2+
import PolygonLayer from './PolygonLayer';
3+
4+
const meta: Meta<typeof PolygonLayer> = {
5+
title: 'Data Visualization/Polygon Layer',
6+
component: PolygonLayer,
7+
parameters: {
8+
layout: 'centered',
9+
storySource: {
10+
source: `
11+
import { AzureMap, AzureMapsProvider, AzureMapDataSourceProvider, AzureMapLayerProvider } from 'react-azure-maps';
12+
import atlas from 'azure-maps-control';
13+
14+
const collection = new atlas.data.Polygon([
15+
[
16+
[-15.82031, 2.46018],
17+
[14.0625, 30.14512],
18+
[40.78125, 2.81137],
19+
[12.30468, 65.21989],
20+
[-15.82031, 2.46018],
21+
],
22+
]);
23+
24+
const PolygonLayer = () => {
25+
26+
return (
27+
<AzureMapsProvider>
28+
<div className="defaultMap">
29+
<AzureMap options={{ ...mapOptions, center: [12, 39], zoom: 0 }}>
30+
<AzureMapDataSourceProvider id="PolygonLayer DataSourceProvider" collection={collection}>
31+
<AzureMapLayerProvider type="PolygonLayer"
32+
options={{ fillColor: 'rgba(0, 0, 255, 0.5)', fillOpacity: 0.8, }} />
33+
</AzureMapDataSourceProvider>
34+
</AzureMap>
35+
</div>
36+
</AzureMapsProvider>
37+
);
38+
};
39+
40+
export default PolygonLayer;
41+
`,
42+
},
43+
},
44+
args: {
45+
fillColor: 'rgba(0, 0, 255, 0.5)',
46+
fillOpacity: 0.8,
47+
},
48+
argTypes: {
49+
fillOpacity: {
50+
control: { type: 'range', min: 0, max: 1, step: 0.1 },
51+
},
52+
},
53+
};
54+
55+
export default meta;
56+
57+
export const Example: StoryObj<typeof PolygonLayer> = {};

0 commit comments

Comments
 (0)