support tomtom map
This commit is contained in:
@@ -104,7 +104,10 @@ export default {
|
||||
}
|
||||
|
||||
if (!this.mapHolder.inited) {
|
||||
const languageInfo = this.$locale.getCurrentLanguageInfo();
|
||||
|
||||
initMapInstance(this.mapHolder, this.$refs.map, {
|
||||
language: languageInfo ? languageInfo.code : null,
|
||||
initCenter: this.initCenter,
|
||||
zoomLevel: this.zoomLevel,
|
||||
text: {
|
||||
|
||||
@@ -38,6 +38,24 @@ const leafletTileSources = {
|
||||
maxZoom: 19,
|
||||
defaultZoomLevel: 14,
|
||||
attribution : '<a href="https://github.com/cyclosm/cyclosm-cartocss-style/releases" title="CyclOSM - Open Bicycle render" class="external" target="_blank">CyclOSM</a> | Map data: © <a href="https://www.openstreetmap.org/copyright" class="external" target="_blank">OpenStreetMap</a> contributors'
|
||||
},
|
||||
'tomtom': {
|
||||
tileUrlFormat: 'https://{s}.api.tomtom.com/map/1/tile/basic/main/{z}/{x}/{y}.png',
|
||||
tileUrlSubDomains: 'abcd',
|
||||
tileUrlExtraParams: [
|
||||
{
|
||||
paramName: 'key',
|
||||
paramValueType: 'tomtom_key'
|
||||
},
|
||||
{
|
||||
paramName: 'language',
|
||||
paramValueType: 'language'
|
||||
}
|
||||
],
|
||||
minZoom: 1,
|
||||
maxZoom: 19,
|
||||
defaultZoomLevel: 14,
|
||||
attribution : '<a href="https://tomtom.com" class="external" target="_blank">© 1992 - 2023 TomTom.</a>'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+19
-6
@@ -46,14 +46,27 @@ export function createLeafletMapInstance(mapHolder, mapContainer, options) {
|
||||
attributionControl: false,
|
||||
zoomControl: false
|
||||
});
|
||||
let mapTileSource = mapConstants.leafletTileSources[mapHolder.mapProvider];
|
||||
let mapTileSource = Object.assign({}, mapConstants.leafletTileSources[mapHolder.mapProvider]);
|
||||
|
||||
if (settings.isMapDataFetchProxyEnabled()) {
|
||||
const mapProxyTileImageUrl = services.generateMapProxyTileImageUrl(mapHolder.mapProvider);
|
||||
mapTileSource = Object.assign({}, mapTileSource, {
|
||||
tileUrlFormat: mapProxyTileImageUrl,
|
||||
tileUrlSubDomains: ''
|
||||
});
|
||||
mapTileSource.tileUrlFormat = services.generateMapProxyTileImageUrl(mapHolder.mapProvider, options.language);
|
||||
mapTileSource.tileUrlSubDomains = '';
|
||||
} else if (mapTileSource.tileUrlExtraParams) {
|
||||
const params = [];
|
||||
|
||||
for (let i = 0; i < mapTileSource.tileUrlExtraParams.length; i++) {
|
||||
const param = mapTileSource.tileUrlExtraParams[i];
|
||||
|
||||
if (param.paramValueType === 'tomtom_key') {
|
||||
params.push('key=' + settings.getTomTomMapAPIKey());
|
||||
} else if (param.paramValueType === 'language' && options.language) {
|
||||
params.push('language=' + options.language);
|
||||
}
|
||||
}
|
||||
|
||||
if (params.length) {
|
||||
mapTileSource.tileUrlFormat = mapTileSource.tileUrlFormat + '?' + params.join('&');
|
||||
}
|
||||
}
|
||||
|
||||
const tileLayer = leaflet.tileLayer(mapTileSource.tileUrlFormat, {
|
||||
|
||||
+8
-2
@@ -396,9 +396,15 @@ export default {
|
||||
ignoreError: !!ignoreError
|
||||
});
|
||||
},
|
||||
generateMapProxyTileImageUrl: (mapProvider) => {
|
||||
generateMapProxyTileImageUrl: (mapProvider, language) => {
|
||||
const token = userState.getToken();
|
||||
return `${api.baseProxyUrlPath}/map/tile/{z}/{x}/{y}.png?provider=${mapProvider}&token=${token}`;
|
||||
let url = `${api.baseProxyUrlPath}/map/tile/{z}/{x}/{y}.png?provider=${mapProvider}&token=${token}`;
|
||||
|
||||
if (language) {
|
||||
url = url + `&language=${language}`;
|
||||
}
|
||||
|
||||
return url;
|
||||
},
|
||||
generateGoogleMapJavascriptUrl: (language, callbackFnName) => {
|
||||
if (language) {
|
||||
|
||||
@@ -181,6 +181,7 @@ export default {
|
||||
isDataExportingEnabled: () => getServerSetting('e') === '1',
|
||||
getMapProvider: () => getServerSetting('m'),
|
||||
isMapDataFetchProxyEnabled: () => getServerSetting('mp') === '1',
|
||||
getTomTomMapAPIKey: () => getServerDecodedSetting('tmak'),
|
||||
getGoogleMapAPIKey: () => getServerDecodedSetting('gmak'),
|
||||
getBaiduMapAK: () => getServerDecodedSetting('bmak'),
|
||||
getAmapApplicationKey: () => getServerDecodedSetting('amak'),
|
||||
|
||||
Reference in New Issue
Block a user