Skip to content

Commit

Permalink
fix: 行政区域 CDN 数据源未同步完整,切换新 CDN 数据源
Browse files Browse the repository at this point in the history
  • Loading branch information
lvisei committed Nov 15, 2023
1 parent 649f8ef commit 46ff346
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,29 @@ export default (props: AreaWidgetProps) => {
};

const getBoundsData = (value: ICity) => {
if (value.level === 'country') return;
setLoading(true);
try {
if (value.level === 'country') return;
const code = value.adcode;
const level = value.level;
fetch(`${BoundsUrl}${level}/${code}_${level}_${level}.json`)
.then((item) => item.json())
.then((res) => {
setLoading(false);
if (showBounds) {
setBoundBorder(res);
return;
}
if (scene && cityData) {
const data = treeToArr([cityData.cities]).find((item: ICity) => item.name === value.name);
if (data) {
scene.setZoomAndCenter(11, [data.lng, data.lat]);
}
const code = value.adcode;
const level = value.level;
fetch(`${BoundsUrl}${level}/${code}_${level}_${level}.json`)
.then((item) => item.json())
.then((res) => {
setLoading(false);
if (showBounds) {
setBoundBorder(res);
return;
}
if (scene && cityData) {
const data = treeToArr([cityData.cities]).find((item: ICity) => item.name === value.name);
if (data) {
scene.setZoomAndCenter(11, [data.lng, data.lat]);
}
});
} catch {
setLoading(false);
message.error('围栏数据请求失败');
}
}
})
.catch(() => {
setLoading(false);
message.error('围栏数据请求失败');
});
};

const onSelectChange = (value: string) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const CLS_PREFIX = 'li-administrative-select';
export const CityUrl = 'https://npm.elemecdn.com/static-geo-atlas@latest/geo-data/administrative-data/area-tree.json';

// 边界数据
export const BoundsUrl = 'https://npm.elemecdn.com/static-geo-atlas@latest/geo-data/choropleth-data/';
export const BoundsUrl = 'https://unpkg.com/static-geo-atlas@latest/geo-data/choropleth-data/';

export const POPOVER_PLACEMENT_LEGEND = new Map<string | undefined, TooltipPlacement>([
['topleft', 'bottomLeft'],
Expand Down

0 comments on commit 46ff346

Please sign in to comment.