Skip to content

Commit d6c2b21

Browse files
committed
zhunhan:add internalUsageAttributionId to examples and README.
1 parent a20e37b commit d6c2b21

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ npm i -D @types/google.maps
3939

4040
The reference documentation can be found at this [link](https://googlemaps.github.io/js-api-loader/index.html). The Google Maps JavaScript API [documentation](https://developers.google.com/maps/documentation/javascript/tutorial) is the authoritative source for the loader options.
4141

42+
## Internal usage attribution ID
43+
44+
This library uses `internalUsageAttributionIds`, which helps Google understand which libraries and samples are helpful to developers and is optional. Instructions for opting out of the identifier are provided in reference documentation.
4245

4346
## Example
4447

@@ -59,6 +62,14 @@ const mapOptions = {
5962
zoom: 4
6063
};
6164

65+
// Adds a usage attribution ID to the initializer, which helps Google understand which libraries and samples are helpful to developers, such as usage of this library.
66+
// To opt out of sending the usage attribution ID, it is safe to set the const to false or replace the value with an empty string.
67+
const useIneternalUsageAttributionId = true;
68+
const internalUsageAttributionId = "GMP_LIB_JS_API_LOADER";
69+
70+
if (useIneternalUsageAttributionId) {
71+
mapOptions.internalUsageAttributionIds = [internalUsageAttributionId];
72+
}
6273
```
6374

6475
Using a promise for a specific library.

examples/index.html

+10
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,16 @@
5050
zoom: 4,
5151
mapId: "DEMO_MAP_ID"
5252
};
53+
54+
// Adds a usage attribution ID to the initializer, which helps Google understand which libraries and samples are helpful to developers, such as usage of this library.
55+
// To opt out of sending the usage attribution ID, it is safe to set the const to false or replace the value with an empty string.
56+
57+
const useInternalUsageAttributionId = true;
58+
const internalUsageAttributionId = "GMP_LIB_JS_API_LOADER";
59+
60+
if (useInternalUsageAttributionId) {
61+
mapOptions.usageAttributionIds = [internalUsageAttributionId];
62+
}
5363

5464
const loader = new google.maps.plugins.loader.Loader({
5565
apiKey: "",

0 commit comments

Comments
 (0)