Select to view content in your preferred language

Adding API key to search widget

743
2
Jump to solution
05-03-2021 03:59 AM
LouisCoetzee
New Contributor

Good day,

Could someone please advise on how I could add / include my API key to the search widget (below)?

 Search widget 

Regards,

Louis

0 Kudos
1 Solution

Accepted Solutions
Noah-Sager
Esri Regular Contributor

Hey @LouisCoetzee, thank for the question. Currently, there are two ways you can use an apiKey with the Search widget.

As of 4.18, you can use a global apiKey with esriConfig, which will work with the Search widget, and any other widget or basemap that requires an apiKey. Example based on your app:

https://codepen.io/noash/pen/yLgmRWK?editors=1000

At 4.19, you can also use a finely-grained apiKey on the LocatorSearchSource property of the Search widget. Example based on your app:

https://codepen.io/noash/pen/bGgXmZq?editors=1000

 

More information about apiKeys in general can be found here: https://developers.arcgis.com/javascript/latest/release-notes/#api-keys

 

 

View solution in original post

0 Kudos
2 Replies
Noah-Sager
Esri Regular Contributor

Hey @LouisCoetzee, thank for the question. Currently, there are two ways you can use an apiKey with the Search widget.

As of 4.18, you can use a global apiKey with esriConfig, which will work with the Search widget, and any other widget or basemap that requires an apiKey. Example based on your app:

https://codepen.io/noash/pen/yLgmRWK?editors=1000

At 4.19, you can also use a finely-grained apiKey on the LocatorSearchSource property of the Search widget. Example based on your app:

https://codepen.io/noash/pen/bGgXmZq?editors=1000

 

More information about apiKeys in general can be found here: https://developers.arcgis.com/javascript/latest/release-notes/#api-keys

 

 

0 Kudos
LouisCoetzee
New Contributor

Hi @Noah-Sager ,

Thank you for your reply and for the examples. 

I have implemented the first example with my API key and it is working. - thank you!

0 Kudos