Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

初期オプションの transformRequest が geolonia のURLに効かない #270

Closed
keichan34 opened this issue Feb 3, 2022 · 2 comments
Labels
question Further information is requested

Comments

@keichan34
Copy link
Member

const _transformRequest = options.transformRequest;
options.transformRequest = (url, resourceType) => {
if (resourceType === 'Source' && url.startsWith('https://api.geolonia.com')) {
return {
url: sourcesUrl.toString(),
};
}
let transformedUrl = url;
if (url.startsWith('geolonia://')) {
const tilesMatch = url.match(/^geolonia:\/\/tiles\/(?<username>.+)\/(?<customtileId>.+)/);
if (tilesMatch) {
transformedUrl = `https://tileserver.geolonia.com/customtiles/${tilesMatch.groups.customtileId}/tiles.json`;
}
}
if (resourceType === 'Source' && transformedUrl.startsWith('https://tileserver.geolonia.com')) {
const tileserverSourcesUrl = new URL(transformedUrl);
if (atts.stage !== 'v1') {
tileserverSourcesUrl.hostname = `tileserver-${atts.stage}.geolonia.com`;
}
tileserverSourcesUrl.searchParams.set('sessionId', sessionId);
tileserverSourcesUrl.searchParams.set('key', atts.key);
return {
url: tileserverSourcesUrl.toString(),
};
}
let request;
// Additional transformation
if (typeof _transformRequest === 'function') {
request = _transformRequest(transformedUrl, resourceType);
}
return request;
};

transformRequest をタイル認証のために使っていますが、geoloniaのソースがリクエストされるときに条件分岐に入ってもともと指定された transformRequest までたどり着けない

@keichan34 keichan34 added the question Further information is requested label Feb 3, 2022
@keichan34
Copy link
Member Author

geoloniaのソースをtransformする必要あるか?

僕は、transformRequestを使って仮にsourceを入れ替えたいけど、かなりユースケースニッチなんですね。 map._requestManager._transformRequestFn の private API で上書きする予定。

@keichan34
Copy link
Member Author

#204 と同じ問題

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant