Skip to content

fix: map config #329

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/GeolocationEditor/country-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,12 @@ class CountryEditor extends Component {

getLocationData = () => {
const { config } = this.props;
const { mediaUrl } = { ...window.dtable, ...config };
const { mediaUrl, server } = { ...window?.dtable, ...config };
let geoFileName = 'en-region-location';
if (this.lang === 'cn') {
geoFileName = 'cn-region-location';
}
return fetch(`${mediaUrl}geo-data/${geoFileName}.json`)
return fetch(`${server}${mediaUrl}geo-data/${geoFileName}.json`.replaceAll('//', '/'))
.then(res => {
return res.json();
})
Expand Down
1 change: 0 additions & 1 deletion src/GeolocationEditor/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@
}

.dtable-ui-geolocation-map-editor .search-tables-input {
line-height: 38px;
padding-right: 30px;
border-bottom: 0;
background: #fff;
Expand Down
3 changes: 3 additions & 0 deletions src/GeolocationEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ class GeolocationEditor extends React.Component {
this.state = {
editorPosition: null,
};
if (!window.app) {
window.app = {};
}
this.editor = null;
}

Expand Down
5 changes: 3 additions & 2 deletions src/GeolocationEditor/location-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,11 @@ class LocationEditor extends Component {
};

getLocationData = () => {
const { mediaUrl } = window.dtable;
const { config } = this.props;
const { mediaUrl, server } = { ...window?.dtable, ...config };

// get locations from server
return fetch(`${mediaUrl}geo-data/cn-location.json`).then((res) => {
return fetch(`${server}${mediaUrl}geo-data/cn-location.json`.replaceAll('//', '/')).then((res) => {
return res.json();
}).catch(() => {
// get locations from local
Expand Down
4 changes: 2 additions & 2 deletions src/GeolocationEditor/map-editor-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const MINE_MAP_ONLINE_SERVICE = {
};

export const getMineMapUrl = (config = {}) => {
const { dtableMineMapCustomConfig = {} } = { ...window.dtable, ...config };
const { dtableMineMapCustomConfig = {} } = { ...window?.dtable, ...config };
const { domain_url = '', data_domain_url = '', server_domain_url = '',
sprite_url = '', service_url = '' } = dtableMineMapCustomConfig;
return {
Expand Down Expand Up @@ -44,7 +44,7 @@ export const getInitCenter = (isSelectionEditor = false) => {
};

export const getMapInfo = (config = {}) => {
const { dtableBaiduMapKey: baiduMapKey, dtableGoogleMapKey: googleMapKey, dtableMineMapKey: mineMapKey } = { ...window.dtable, ...config };
const { dtableBaiduMapKey: baiduMapKey, dtableGoogleMapKey: googleMapKey, dtableMineMapKey: mineMapKey } = { ...window?.dtable, ...config };
let mapType;
let mapKey;
if (baiduMapKey) {
Expand Down
2 changes: 1 addition & 1 deletion src/GeolocationEditor/map-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class MapEditor extends Component {
loadMineMapCallBack = () => {
if (!this.timer) {
this.timer = setTimeout(() => {
const { domainUrl, dataDomainUrl, serverDomainUrl, spriteUrl, serviceUrl } = getMineMapUrl();
const { domainUrl, dataDomainUrl, serverDomainUrl, spriteUrl, serviceUrl } = getMineMapUrl(this.props.config);
window.minemap.domainUrl = domainUrl;
window.minemap.dataDomainUrl = dataDomainUrl;
window.minemap.serverDomainUrl = serverDomainUrl;
Expand Down
1 change: 0 additions & 1 deletion src/GeolocationEditor/map-editor/large-editor/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
}

.dtable-ui-large-map-editor-dialog .dtable-ui-geolocation-map-editor-large .search-tables-input {
line-height: 38px;
padding-right: 30px;
border-bottom: 0;
background: #fff;
Expand Down
2 changes: 1 addition & 1 deletion src/GeolocationEditor/map-editor/large-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class LargeMapEditorDialog extends React.Component {
loadMineMapCallBack = () => {
if (!this.timer) {
this.timer = setTimeout(() => {
const { domainUrl, dataDomainUrl, serverDomainUrl, spriteUrl, serviceUrl } = getMineMapUrl();
const { domainUrl, dataDomainUrl, serverDomainUrl, spriteUrl, serviceUrl } = getMineMapUrl(this.props.config);
window.minemap.domainUrl = domainUrl;
window.minemap.dataDomainUrl = dataDomainUrl;
window.minemap.serverDomainUrl = serverDomainUrl;
Expand Down
2 changes: 1 addition & 1 deletion src/GeolocationEditor/map-selection-editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MapSelectionEditor extends Component {
}

componentWillUnmount() {
if (this.mapType === MAP_TYPES.B_MAP) {
if (this.map && this.mapType === MAP_TYPES.B_MAP) {
let center = {};
center.zoom = this.map.getZoom();
let coordinate = this.map.getCenter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class LargeMapSelectionEditorDialog extends React.Component {
}

componentWillUnmount() {
if (this.mapType === MAP_TYPES.B_MAP) {
if (this.map && this.mapType === MAP_TYPES.B_MAP) {
let center = {};
center.zoom = this.map.getZoom();
let coordinate = this.map.getCenter();
Expand Down
5 changes: 3 additions & 2 deletions src/GeolocationEditor/province-city-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ class ProvinceCityEditor extends Component {
};

getLocationData = () => {
const { mediaUrl } = window.dtable;
const { config } = this.props;
const { mediaUrl, server } = { ...window?.dtable, ...config };

// get locations from server
return fetch(`${mediaUrl}geo-data/cn-location.json`).then((res) => {
return fetch(`${server}${mediaUrl}geo-data/cn-location.json`.replaceAll('//', '/')).then((res) => {
return res.json();
}).catch(() => {
// get locations from local
Expand Down
5 changes: 3 additions & 2 deletions src/GeolocationEditor/province-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ class ProvinceEditor extends Component {

getLocationData = () => {
// mediaUrl
const { mediaUrl } = window.dtable;
const { config } = this.props;
const { mediaUrl, server } = { ...window?.dtable, ...config };
// get locations from server
return fetch(`${mediaUrl}geo-data/cn-location.json`).then((res) => {
return fetch(`${server}${mediaUrl}geo-data/cn-location.json`.replaceAll('//', '/')).then((res) => {
return res.json();
}).catch(() => {
// get locations from local
Expand Down
7 changes: 4 additions & 3 deletions src/RowExpandEditor/RowExpandGeolocationEditor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,14 @@ class RowExpandGeolocationEditor extends React.Component {
};

getLocationInfo = (value) => {
const { column } = this.props;
const { dtableBaiduMapKey, dtableMineMapKey } = window.dtable;
const { column, config } = this.props;
const { dtableBaiduMapKey, dtableMineMapKey } = { ...window?.dtable, ...config };
const isBaiduMap = !!(dtableBaiduMapKey || dtableMineMapKey);
return getGeolocationDisplayString(value, column.data, { isBaiduMap, hyphen: ' ' });
};

render() {
const { column, row } = this.props;
const { column, row, config } = this.props;
const { value } = this.state;
return (
<div ref={ref => this.editorContainer = ref} className="mt-2">
Expand All @@ -140,6 +140,7 @@ class RowExpandGeolocationEditor extends React.Component {
ref={ref => this.geoEditor = ref}
isInModal={true}
column={column}
config={config}
row={row}
value={value}
onCommit={this.onCommit}
Expand Down