Skip to content

Commit

Permalink
added suggestApiKey setting, it's required now for proper requests co…
Browse files Browse the repository at this point in the history
…unting
  • Loading branch information
pytnik89 committed Sep 6, 2023
1 parent b32f666 commit 1f51b20
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/en/guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ These settings are optional and below you can see default options:
```JavaScript
const settings = {
apiKey: '',
suggestApiKey: '',
lang: 'ru_RU',
coordorder: 'latlong',
enterprise: false,
Expand Down
1 change: 1 addition & 0 deletions docs/guide/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ npm install vue-yandex-maps
```JavaScript
const settings = {
apiKey: '',
suggestApiKey: '',
lang: 'ru_RU',
coordorder: 'latlong',
enterprise: false,
Expand Down
4 changes: 3 additions & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,16 @@ export function ymapLoader(settings = {}) {
const yandexMapScript = document.createElement('SCRIPT');
const {
apiKey = '',
suggestApiKey = '',
lang = 'ru_RU',
version = '2.1',
coordorder = 'latlong',
debug = false,
enterprise = false,
} = settings;
const mode = debug ? 'debug' : 'release';
const settingsPart = `lang=${lang}${apiKey && `&apikey=${apiKey}`}&mode=${mode}&coordorder=${coordorder}`;
let settingsPart = `lang=${lang}${apiKey && `&apikey=${apiKey}`}&mode=${mode}&coordorder=${coordorder}`;
if (suggestApiKey) settingsPart += `&suggest_apikey=${suggestApiKey}`;
const link = `https://${enterprise ? 'enterprise.' : ''}api-maps.yandex.ru/${version}/?${settingsPart}`;
yandexMapScript.setAttribute('src', link);
yandexMapScript.setAttribute('async', '');
Expand Down

0 comments on commit 1f51b20

Please sign in to comment.