Skip to content

Commit 5afd107

Browse files
author
Savina Shen (Manpower Services Taiwan Co Ltd)
committed
anonymous authentication and final check
1 parent c6e9d9d commit 5afd107

File tree

9 files changed

+94
-47
lines changed

9 files changed

+94
-47
lines changed

src/key.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ export const key = process.env.STORYBOOK_AZURE_MAPS_KEY || '';
44

55
export const mapOptions: IAzureMapOptions = {
66
authOptions: {
7-
authType: AuthenticationType.subscriptionKey,
8-
subscriptionKey: key,
7+
authType: AuthenticationType.anonymous,
8+
clientId: '2a60774c-f588-423b-b004-56d213773ee6',
9+
getToken: (resolve, reject) => {
10+
fetch('https://anonymous-auth.azurewebsites.net/api/GetAccessToken-Prod')
11+
.then((result) => result.text())
12+
.then((result) => resolve(result))
13+
.catch((error) => reject(new Error(`Failed to fetch anon auth token: ${error.message}`)));
14+
},
915
},
1016
center: [0, 0],
1117
view: 'Auto',

src/stories/BasicUsage/MapRef/MapRef.mdx

+11-4
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,19 @@ Remember to wrap your component with AzureMapsProvider to provide the necessary
3333
import { AzureMapsProvider } from 'react-azure-maps';
3434
import YourComponent from './YourComponent';
3535
36-
<AzureMapsProvider>
37-
<YourComponent/>
38-
</AzureMapsProvider>
36+
const NewComponent = () => {
37+
return(
38+
<AzureMapsProvider>
39+
<YourComponent/>
40+
</AzureMapsProvider>
41+
);
42+
}
3943
`}/>
4044

4145
## Examples
46+
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!
48+
4249
In the first example, we use the `setCamera()` function to change the center of the map. <br/>
4350
Click the button to see the effect.
4451

@@ -75,7 +82,7 @@ const SetCenter = () => {
7582
);
7683
};
7784
78-
const getRandomPosition = () => {
85+
function getRandomPosition() {
7986
const randomLongitude = Math.floor(Math.random() * (180 - -180) + -180);
8087
const randomLatitude = Math.floor(Math.random() * (-90 - 90) + 90);
8188
return [randomLatitude, randomLongitude];

src/stories/DataVisualization/HeatMapLayer/HeatMapLayer.mdx

+28-29
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ 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/>
11-
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)
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/>
11+
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}/>
1414

@@ -62,37 +62,36 @@ You can customize the color of the heat map layer by passing the `color` prop li
6262

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

68-
<HeatMapLayer
69-
radius={10}
70-
weight={[
71-
'interpolate',
72-
['exponential', 2], //Using an exponential interpolation since earthquake magnitudes are on an exponential scale.
73-
['get', 'mag'],
74-
0,
75-
0,
76-
10,
77-
1,
78-
]}/>
68+
<HeatMapLayer
69+
radius={10}
70+
weight={[
71+
'interpolate',
72+
//Using an exponential interpolation since earthquake magnitudes are on an exponential scale.
73+
['exponential', 2],
74+
['get', 'mag'],
75+
0,
76+
0,
77+
10,
78+
1,
79+
]}
80+
/>;
7981

8082
<Source code={`
81-
<AzureMapLayerProvider
82-
type="HeatLayer"
83-
options={{
84-
radius: 10,
85-
weight: [
86-
'interpolate',
87-
['exponential', 2], //Using an exponential interpolation since earthquake magnitudes are on an exponential scale.
88-
['get', 'mag'],
89-
0,
90-
0,
91-
10,
92-
1,
93-
]
94-
}}
95-
/>
83+
<HeatMapLayer
84+
radius={10}
85+
weight={[
86+
'interpolate',
87+
['exponential', 2],
88+
['get', 'mag'],
89+
0,
90+
0,
91+
10,
92+
1,
93+
]}
94+
/>;
9695
`}/>
9796

9897

src/stories/DataVisualization/HeatMapLayer/HeatMapLayer.stories.ts

+38
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,44 @@ const meta: Meta<typeof HeatMapLayer> = {
66
component: HeatMapLayer,
77
parameters: {
88
controls: { exclude: ['color'] },
9+
storySource: {
10+
source: `
11+
import { AzureMap, AzureMapsProvider, AzureMapDataSourceProvider, AzureMapLayerProvider } from 'react-azure-maps';
12+
13+
const magWeight = [
14+
'interpolate',
15+
['exponential', 2], //Using an exponential interpolation since earthquake magnitudes are on an exponential scale.
16+
['get', 'mag'],
17+
0,
18+
0,
19+
10,
20+
1,
21+
];
22+
23+
const HeatMapLayer = () => {
24+
return (
25+
<AzureMapsProvider>
26+
<AzureMap options={your_options}>
27+
<AzureMapDataSourceProvider
28+
id="LineLayer DataSourceProvider"
29+
dataFromUrl="https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson"
30+
>
31+
<AzureMapLayerProvider
32+
type="HeatLayer"
33+
options={{
34+
radius: 10,
35+
opacity: 1,
36+
intensity: 1,
37+
weight: 1, // if weight is set true in the Controls, magWeight is used
38+
}}
39+
/>
40+
</AzureMapDataSourceProvider>
41+
</AzureMap>
42+
</AzureMapsProvider>
43+
);
44+
};
45+
`,
46+
},
947
},
1048
args: {
1149
radius: 10,

src/stories/DataVisualization/ImageLayer/ImageLayer.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You can overlay an image to a fixed set of coordinates with the Image Layer.<br/
1010
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**.
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/TileLayer/TileLayer.stories.ts

-3
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ return (
2929
</AzureMapsProvider>
3030
);
3131
};
32-
33-
export default TileLayer;
34-
3532
`,
3633
},
3734
},

src/stories/DefaultMap/GettingStarted.mdx

+6-6
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ const option: IAzureMapOptions = {
5252
};
5353
5454
const DefaultMap = () => (
55-
<AzureMapsProvider>
56-
<div>
55+
<div style={{width:'700px', height: '300px'}}>
56+
<AzureMapsProvider>
5757
<AzureMap options={option} />
58-
</div>
59-
</AzureMapsProvider>
58+
</AzureMapsProvider>
59+
</div>
6060
);
6161
`} />
6262

@@ -105,7 +105,7 @@ There are three main references that depend on the basic `Azure Maps API`:
105105
- See [Default Map](#create-a-map) as an example.
106106
#### AzureMapDataSourceProvider
107107
- provides the data source instance and references to the data source.
108-
- See [Data Visualization]() for more usages.
108+
- See [Data Visualization Introduction](/docs/data-visualization-introduction--docs) for more usages.
109109
#### AzureMapLayerProvider
110110
- provides the layer instance and references to the layer.
111-
- See [Data Visualization]() and for more usages.
111+
- See [Data Visualization](/docs/data-visualization-introduction--docs) for more usages.

src/stories/Events/MapEvents/MapEvents.mdx

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const MapEvents = () => {
2020
const [position, setPosition] = useState([0, 0]);
2121
2222
const handleMapClick = (e: any) => {
23+
// get the position of the click event
2324
setPosition(e.position);
2425
};
2526
const displayPosition = (position: number[]) => {

src/stories/MapAnnotations/HtmlMarker/HtmlMarker.mdx

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ Following is a simple example of how to use the HtmlMarker component. <br/>
1212
You can customize the marker by setting the [options prop](https://learn.microsoft.com/en-us/javascript/api/azure-maps-control/atlas.htmlmarkeroptions?view=azure-maps-typescript-latest).
1313

1414
<HtmlMarker text='10'/>
15-
{/* show basic code */}
1615

1716
<Source code={`
1817
<AzureMapHtmlMarker options={{ text: '10' }}/>
@@ -21,5 +20,5 @@ You can customize the marker by setting the [options prop](https://learn.microso
2120
You can also pass a **custom component** to the marker. <br/>
2221
Noted that the custom component will be rendered into a static element.
2322
<Source code={`
24-
<AzureMapHtmlMarker options={{ position }} markerContent={<YourComponent/>} />
23+
<AzureMapHtmlMarker markerContent={<YourComponent/>} />
2524
`} />

0 commit comments

Comments
 (0)