improvement(district): 增加世界地图,市,县地图

This commit is contained in:
thinkinggis 2020-04-26 16:45:30 +08:00
parent 5910ff3f2e
commit d67fe5eaaa
21 changed files with 968 additions and 27750 deletions

View File

@ -103,7 +103,6 @@
"rollup-pluginutils": "^2.8.2",
"sass-loader": "^7.1.0",
"style-loader": "^1.0.0",
"three": "0.115.0",
"styled-components": "^3.4.6",
"stylelint": "^9.5.0",
"stylelint-config-recommended": "^2.1.0",
@ -111,6 +110,7 @@
"stylelint-config-styled-components": "^0.1.1",
"stylelint-processor-styled-components": "^1.3.2",
"svg-inline-loader": "^0.8.0",
"three": "0.115.0",
"ts-jest": "^24.0.2",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0",

View File

@ -36,12 +36,14 @@
"dependencies": {
"@antv/l7": "^2.2.0",
"@babel/runtime": "^7.7.7",
"@turf/turf": "^5.1.6",
"@turf/circle": "^6.0.1",
"@turf/distance": "^6.0.1",
"@turf/helpers": "^6.1.4",
"@turf/midpoint": "^5.1.5",
"lodash": "^4.6.2"
"@turf/turf": "^5.1.6",
"geobuf": "^3.0.1",
"lodash": "^4.6.2",
"pbf": "^3.2.1"
},
"peerDependencies": {
"@antv/l7": "^2.1.15"

View File

@ -1,16 +1,83 @@
export default {
// tslint:disable-next-line:no-submodule-imports
import merge from 'lodash/merge';
let DataConfig: { [key: string]: any } = {
world: {
fill: '',
line: '',
fill: {
type: 'pbf',
url:
'https://gw.alipayobjects.com/os/bmw-prod/cc78dddf-28ca-49a1-955a-33fa0525be6b.bin',
},
label: {
type: 'pbf',
url:
'https://gw.alipayobjects.com/os/bmw-prod/90c51eb3-04d7-402f-bd05-95e4bd27dd62.bin',
parser: {
type: 'geojson',
},
},
nationalBoundaries: {
type: 'json',
url:
'https://gw.alipayobjects.com/os/bmw-prod/ee493a41-0558-4c0e-bee6-520276c4f1a8.json',
},
},
country: {
CHN: {
fill: '',
line: '',
label: '',
1: {
fill: {
type: 'pbf',
url:
'https://gw.alipayobjects.com/os/bmw-prod/4f359a06-439e-435f-b74a-20ef867e1f50.bin',
},
line: {
type: 'json',
url:
'https://gw.alipayobjects.com/os/bmw-prod/06212bc5-2927-4f95-a1c1-32ec380fdffa.json',
},
label: {
type: 'json',
url:
'https://gw.alipayobjects.com/os/bmw-prod/36832a45-68f8-4b51-b006-9dec71f92a23.json',
},
},
2: {
fill: {
type: 'pbf',
url:
'https://gw.alipayobjects.com/os/bmw-prod/c631009a-fe19-4a05-8c59-100532ae5383.bin',
},
},
3: {
fill: {
type: 'pbf',
url:
'https://gw.alipayobjects.com/os/bmw-prod/53e53fc2-5476-4d22-9725-898ad91b0fdf.bin',
},
},
nationalBoundaries: {
type: 'json',
url:
'https://gw.alipayobjects.com/os/bmw-prod/ee493a41-0558-4c0e-bee6-520276c4f1a8.json',
},
nationalBoundaries2: {
type: 'json',
url:
'https://gw.alipayobjects.com/os/bmw-prod/f2189cc4-662b-4358-8573-36f0f918b7ca.json',
},
island: {
type: 'json',
url:
'https://gw.alipayobjects.com/os/bmw-prod/fe49b393-1147-4769-94ed-70471f4ff15d.json',
},
},
},
province: {
110000: '',
},
};
function setDataConfig(config: any) {
DataConfig = merge(DataConfig, config);
}
export { setDataConfig, DataConfig };

File diff suppressed because it is too large Load Diff

View File

@ -1,37 +0,0 @@
const labelData = [
{ name: '北京', center: [116.405285, 40.404989] },
{ name: '天津', center: [117.590182, 39.125596] },
{ name: '河北', center: [115.502461, 38.045474] },
{ name: '山西', center: [112.249248, 37.857014] },
{ name: '内蒙古', center: [110.670801, 41.018311] },
{ name: '辽宁', center: [123.429096, 41.396767] },
{ name: '吉林', center: [125.6245, 43.886841] },
{ name: '黑龙江', center: [127.242464, 46.756967] },
{ name: '上海', center: [122.472644, 31.231706] },
{ name: '江苏', center: [119.767413, 32.541544] },
{ name: '浙江', center: [120.153576, 29.287459] },
{ name: '安徽', center: [117.083042, 31.86119] },
{ name: '福建', center: [118.306239, 26.075302] },
{ name: '江西', center: [115.592151, 27.676493] },
{ name: '山东', center: [118.000923, 36.375807] },
{ name: '河南', center: [113.665412, 33.757975] },
{ name: '湖北', center: [112.598572, 30.984355] },
{ name: '湖南', center: [111.982279, 27.69409] },
{ name: '广东', center: [114.280637, 23.625178] },
{ name: '广西', center: [108.820004, 23.32402] },
{ name: '海南', center: [110.33119, 19.031971] },
{ name: '重庆', center: [107.504962, 29.533155] },
{ name: '四川', center: [103.065735, 30.659462] },
{ name: '贵州', center: [106.713478, 26.578343] },
{ name: '云南', center: [101.712251, 24.540609] },
{ name: '西藏', center: [90.132212, 30.660361] },
{ name: '陕西', center: [108.948024, 34.263161] },
{ name: '甘肃', center: [104.023557, 35.558039] },
{ name: '青海', center: [96.778916, 35.623178] },
{ name: '宁夏', center: [106.278179, 37.46637] },
{ name: '新疆', center: [85.617733, 40.792818] },
{ name: '台湾', center: [121.509062, 24.044332] },
{ name: '香港', center: [114.299346, 22.302742] },
{ name: '澳门', center: [112.54909, 21.738951] },
];
export default labelData;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1,4 @@
import { setDataConfig } from './config';
import CountryLayer from './layer/country';
export { CountryLayer };
import WorldLayer from './layer/world';
export { WorldLayer, CountryLayer, setDataConfig };

View File

@ -0,0 +1,180 @@
import {
ILayer,
IPopup,
LineLayer,
PointLayer,
PolygonLayer,
Popup,
Scene,
StyleAttrField,
} from '@antv/l7';
// @ts-ignore
import geobuf from 'geobuf';
// tslint:disable-next-line: no-submodule-imports
import merge from 'lodash/merge';
// @ts-ignore
import Pbf from 'pbf';
import { IDistrictLayerOption } from './interface';
export default class BaseLayer {
public fillLayer: ILayer;
protected scene: Scene;
protected options: IDistrictLayerOption;
protected layers: ILayer[] = [];
private popup: IPopup;
constructor(scene: Scene, option: Partial<IDistrictLayerOption> = {}) {
this.scene = scene;
this.options = merge(this.getdefaultOption(), option);
}
public destroy() {
this.layers.forEach((layer) => this.scene.removeLayer(layer));
this.layers.length = 0;
}
public show() {
this.layers.forEach((layer) => layer.show());
}
public hide() {
this.layers.forEach((layer) => layer.hide());
}
protected async fetchData(data: { url: string; type: string }) {
if (data.type === 'pbf') {
const buffer = await (await fetch(data.url)).arrayBuffer();
const geojson = geobuf.decode(new Pbf(buffer));
return geojson;
} else {
return (await fetch(data.url)).json();
}
}
protected getdefaultOption(): IDistrictLayerOption {
return {
zIndex: 0,
depth: 1,
label: {
enable: true,
color: '#000',
field: 'name',
size: 8,
stroke: '#fff',
strokeWidth: 2,
textAllowOverlap: true,
opacity: 1,
},
fill: {
scale: null,
field: null,
values: '#fff',
},
autoFit: true,
stroke: '#d95f0e',
strokeWidth: 0.6,
coastlineStroke: '#4190da',
coastlineWidth: 1,
nationalStroke: 'gray',
nationalWidth: 1,
popup: {
enable: true,
triggerEvent: 'mousemove',
Html: (properties: any) => {
return `${properties.name}`;
},
},
};
}
protected addFillLayer(fillCountry: any) {
// 添加省份填充
const { popup, data = [], fill, autoFit } = this.options;
const fillLayer = new PolygonLayer({
autoFit,
}).source(fillCountry, {
transforms:
data.length === 0
? []
: [
{
type: 'join',
sourceField: 'name', // data1 对应字段名
targetField: 'name', // data 对应字段名 绑定到的地理数据
data,
},
],
});
fill.field
? fillLayer.color(fill.field, fill.values)
: fillLayer.color(fill.values as string);
if (fill.scale) {
fillLayer.scale('color', {
type: 'quantile',
field: fill.field as string,
});
}
fillLayer
.shape('fill')
.active({
color: 'rgba(0,0,255,0.3)',
})
.style({
opacity: 1,
});
this.fillLayer = fillLayer;
this.layers.push(fillLayer);
this.scene.addLayer(fillLayer);
if (popup.enable) {
this.addPopup();
}
}
protected addFillLine(provinceLine: any) {
const { stroke, strokeWidth } = this.options;
const layer2 = new LineLayer({
zIndex: 2,
})
.source(provinceLine)
.color(stroke)
.size(strokeWidth)
.style({
opacity: 1,
});
this.scene.addLayer(layer2);
this.layers.push(layer2);
}
protected addLableLayer(labelData: any, type: string = 'json') {
const { label, zIndex } = this.options;
const labelLayer = new PointLayer({
zIndex: zIndex + 2,
})
.source(labelData, {
parser: {
type,
coordinates: 'center',
},
})
.color(label.color as StyleAttrField)
.shape(label.field as StyleAttrField, 'text')
.size(10)
.style({
opacity: label.opacity,
stroke: label.stroke,
strokeWidth: label.strokeWidth,
textAllowOverlap: label.textAllowOverlap,
});
this.scene.addLayer(labelLayer);
this.layers.push(labelLayer);
}
protected addPopup() {
const { popup } = this.options;
this.fillLayer.on('mousemove', (e) => {
this.popup = new Popup({
closeButton: false,
})
.setLnglat(e.lngLat)
.setHTML(popup.Html ? popup.Html(e.feature.properties) : '');
this.scene.addPopup(this.popup);
});
}
}

View File

@ -3,75 +3,45 @@ import {
LineLayer,
PointLayer,
PolygonLayer,
Popup,
Scene,
StyleAttrField,
} from '@antv/l7';
import merge from 'lodash/merge';
import fillCountry from '../data/country';
import labelData from '../data/label';
import { boundaries, boundaries2, island } from '../data/line';
import provinceLine from '../data/provinceline';
import { DataConfig } from '../config';
import BaseLayer from './baseLayer';
import { IDistrictLayerOption } from './interface';
export default class CountryLayer {
private scene: Scene;
private options: IDistrictLayerOption;
private layers: ILayer[] = [];
private fillLayer: ILayer;
export default class CountryLayer extends BaseLayer {
constructor(scene: Scene, option: Partial<IDistrictLayerOption> = {}) {
this.scene = scene;
this.options = merge(this.getdefaultOption(), option);
this.addNationBorder();
this.addFillLayer();
if (this.options.label?.enable) {
this.addLableLayer();
}
}
public destroy() {
this.layers.forEach((layer) => this.scene.removeLayer(layer));
this.layers.length = 0;
}
public show() {
this.layers.forEach((layer) => layer.show());
}
public hide() {
this.layers.forEach((layer) => layer.hide());
}
private getdefaultOption(): IDistrictLayerOption {
return {
zIndex: 0,
depth: 1,
label: {
enable: true,
color: '#000',
field: 'name',
size: 8,
stroke: '#fff',
strokeWidth: 2,
textAllowOverlap: true,
opacity: 1,
super(scene, option);
this.loadData().then(
([fillData, fillLine, fillLabel, borld1, borld2, island]) => {
this.addNationBorder(borld1, borld2, island);
this.addFillLayer(fillData);
this.addFillLine(fillLine || fillData);
if (fillLabel && this.options.label?.enable) {
this.addLableLayer(fillLabel);
}
},
fill: {
scale: null,
field: null,
values: '#fff',
},
stroke: '#d95f0e',
strokeWidth: 0.6,
coastlineStroke: '#4190da',
coastlineWidth: 1,
nationalStroke: 'gray',
nationalWidth: 1,
popup: {
enable: true,
triggerEvent: 'mousemove',
},
};
);
}
private async loadData() {
const { depth } = this.options;
const countryConfig = DataConfig.country.CHN[depth];
const bordConfig = DataConfig.country.CHN;
const fillData = await this.fetchData(countryConfig.fill);
const fillLine = countryConfig.line
? await this.fetchData(countryConfig.line)
: null;
const fillLabel = countryConfig.label
? await this.fetchData(countryConfig.label)
: null;
const borld1 = await this.fetchData(bordConfig.nationalBoundaries);
const borld2 = await this.fetchData(bordConfig.nationalBoundaries2);
const island = await this.fetchData(bordConfig.island);
return [fillData, fillLine, fillLabel, borld1, borld2, island];
}
// 添加行政区边界
private addNationBorder() {
private addNationBorder(boundaries: any, boundaries2: any, island: any) {
const {
nationalStroke,
nationalWidth,
@ -84,7 +54,7 @@ export default class CountryLayer {
zIndex: zIndex + 1,
})
.source(boundaries)
.color('type', (v: number) => {
.size('type', (v: number) => {
return v * 1 === 0 ? coastlineWidth : nationalWidth;
})
.shape('line')
@ -96,7 +66,7 @@ export default class CountryLayer {
zIndex: zIndex + 1,
})
.source(boundaries2)
.size(1)
.size(nationalWidth)
.shape('line')
.color('gray')
.style({
@ -127,88 +97,4 @@ export default class CountryLayer {
this.scene.addLayer(fillLayer2);
this.layers.push(lineLayer, lineLayer2, fillLayer1, fillLayer2);
}
private addFillLayer() {
// 添加省份填充
const { stroke, strokeWidth, popup, data = [], fill } = this.options;
const fillLayer = new PolygonLayer().source(fillCountry, {
transforms: [
{
type: 'join',
sourceField: 'name', // data1 对应字段名
targetField: 'name', // data 对应字段名 绑定到的地理数据
data,
},
],
});
fill.field
? fillLayer.color(fill.field, fill.values)
: fillLayer.color(fill.values as string);
if (fill.scale) {
fillLayer.scale('color', {
type: 'quantile',
field: fill.field as string,
});
}
fillLayer
.shape('fill')
.active({
color: 'rgba(0,0,255,0.3)',
})
.style({
opacity: 1,
});
this.fillLayer = fillLayer;
// 添加省份边界
const layer2 = new LineLayer({
zIndex: 2,
})
.source(provinceLine)
.color(stroke)
.size(strokeWidth)
.style({
opacity: 1,
});
this.scene.addLayer(fillLayer);
this.scene.addLayer(layer2);
this.layers.push(fillLayer, layer2);
if (popup.enable) {
this.addPopup();
}
}
private addLableLayer() {
const { label, zIndex } = this.options;
const labelLayer = new PointLayer({
zIndex: zIndex + 2,
})
.source(labelData, {
parser: {
type: 'json',
coordinates: 'center',
},
})
.color(label.color)
.shape(label.field, 'text')
.size(10)
.style({
opacity: label.opacity,
stroke: label.stroke,
strokeWidth: label.strokeWidth,
textAllowOverlap: label.textAllowOverlap,
});
this.scene.addLayer(labelLayer);
this.layers.push(labelLayer);
}
private addPopup() {
this.fillLayer.on('mousemove', (e) => {
const popup = new Popup({
closeButton: false,
})
.setLnglat(e.lngLat)
.setHTML(`<span>省份: ${e.feature.properties.name}</span>`);
this.scene.addPopup(popup);
});
}
}

View File

@ -1,31 +1,34 @@
import { ScaleTypeName, StyleAttributeOption } from '@antv/l7';
export interface ILabelOption {
enable: boolean;
color: string;
field: string;
size: number;
stroke: string;
strokeWidth: number;
textAllowOverlap: boolean;
opacity: number;
}
export interface IDistrictLayerOption {
zIndex: number;
data?: Array<{ [key: string]: any }>;
depth: 0 | 1 | 2;
label: {
enable: boolean;
color: string;
field: string;
size: number;
stroke: string;
strokeWidth: number;
textAllowOverlap: boolean;
opacity: number;
};
fill: {
depth: 0 | 1 | 2 | 3;
label: Partial<ILabelOption>;
fill: Partial<{
scale: ScaleTypeName | null;
field: string | null;
values: StyleAttributeOption;
};
}>;
autoFit: boolean;
stroke: string;
strokeWidth: number;
coastlineStroke: string;
coastlineWidth: number;
nationalStroke: string;
nationalWidth: number;
popup: {
popup: Partial<{
enable: boolean;
triggerEvent: 'mousemove' | 'click';
};
Html: (properties: any) => string;
}>;
}

View File

@ -0,0 +1,31 @@
import {
ILayer,
LineLayer,
PointLayer,
PolygonLayer,
Scene,
StyleAttrField,
} from '@antv/l7';
import { DataConfig } from '../config';
import BaseLayer from './baseLayer';
import { IDistrictLayerOption } from './interface';
export default class WorldLayer extends BaseLayer {
constructor(scene: Scene, option: Partial<IDistrictLayerOption> = {}) {
super(scene, option);
this.loadData().then(([fillData, fillLabel]) => {
// this.addWorldBorder(borld1, borld2, island);
this.addFillLayer(fillData);
this.addFillLine(fillData);
if (this.options.label?.enable) {
this.addLableLayer(fillLabel, 'geojson');
}
});
}
private async loadData() {
const countryConfig = DataConfig.world;
const fillData = await this.fetchData(countryConfig.fill);
const fillLabel = await this.fetchData(countryConfig.label);
return [fillData, fillLabel];
}
}

View File

@ -20,7 +20,7 @@ export default class Country extends React.Component {
style: 'blank',
zoom: 3,
minZoom: 3,
maxZoom: 4,
maxZoom: 10,
}),
});
scene.on('loaded', () => {
@ -266,11 +266,19 @@ export default class Country extends React.Component {
];
const Layer = new CountryLayer(scene, {
data,
depth: 1,
fill: {
scale: 'quantile',
field: 'confirm',
values: ['#feedde','#fdd0a2','#fdae6b','#fd8d3c','#e6550d','#a63603']
}
values: [
'#feedde',
'#fdd0a2',
'#fdae6b',
'#fd8d3c',
'#e6550d',
'#a63603',
],
},
});
});
this.scene = scene;

View File

@ -0,0 +1,351 @@
import { Scene } from '@antv/l7';
import { CountryLayer } from '@antv/l7-district';
import { GaodeMap, Mapbox } from '@antv/l7-maps';
import * as React from 'react';
export default class Country extends React.Component {
// @ts-ignore
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const scene = new Scene({
id: 'map',
map: new Mapbox({
center: [116.2825, 39.9],
pitch: 0,
style: 'blank',
zoom: 3,
minZoom: 1,
maxZoom: 4,
}),
});
const data = [
{
name: '湖北',
confirm: 16678,
suspect: 0,
heal: 533,
dead: 479,
},
{
name: '广东',
confirm: 895,
suspect: 0,
heal: 37,
dead: 0,
},
{
name: '浙江',
confirm: 895,
suspect: 0,
heal: 65,
dead: 0,
},
{
name: '河南',
confirm: 764,
suspect: 0,
heal: 41,
dead: 2,
},
{
name: '湖南',
confirm: 661,
suspect: 0,
heal: 35,
dead: 0,
},
{
name: '江西',
confirm: 548,
suspect: 0,
heal: 27,
dead: 0,
},
{
name: '安徽',
confirm: 530,
suspect: 0,
heal: 20,
dead: 0,
},
{
name: '重庆',
confirm: 376,
suspect: 0,
heal: 15,
dead: 2,
},
{
name: '江苏',
confirm: 341,
suspect: 0,
heal: 13,
dead: 0,
},
{
name: '山东',
confirm: 307,
suspect: 0,
heal: 13,
dead: 0,
},
{
name: '四川',
confirm: 301,
suspect: 0,
heal: 23,
dead: 1,
},
{
name: '北京',
confirm: 253,
suspect: 0,
heal: 24,
dead: 1,
},
{
name: '上海',
confirm: 243,
suspect: 0,
heal: 15,
dead: 1,
},
{
name: '福建',
confirm: 205,
suspect: 0,
heal: 7,
dead: 0,
},
{
name: '黑龙江',
confirm: 190,
suspect: 0,
heal: 7,
dead: 2,
},
{
name: '陕西',
confirm: 165,
suspect: 0,
heal: 6,
dead: 0,
},
{
name: '广西',
confirm: 150,
suspect: 0,
heal: 10,
dead: 0,
},
{
name: '河北',
confirm: 135,
suspect: 0,
heal: 4,
dead: 1,
},
{
name: '云南',
confirm: 124,
suspect: 0,
heal: 5,
dead: 0,
},
{
name: '海南',
confirm: 91,
suspect: 0,
heal: 4,
dead: 1,
},
{
name: '辽宁',
confirm: 81,
suspect: 0,
heal: 3,
dead: 0,
},
{
name: '山西',
confirm: 81,
suspect: 0,
heal: 4,
dead: 0,
},
{
name: '天津',
confirm: 69,
suspect: 0,
heal: 2,
dead: 1,
},
{
name: '贵州',
confirm: 64,
suspect: 0,
heal: 8,
dead: 0,
},
{
name: '甘肃',
confirm: 57,
suspect: 0,
heal: 4,
dead: 0,
},
{
name: '吉林',
confirm: 54,
suspect: 0,
heal: 1,
dead: 0,
},
{
name: '内蒙古',
confirm: 42,
suspect: 0,
heal: 3,
dead: 0,
},
{
name: '宁夏',
confirm: 34,
suspect: 0,
heal: 1,
dead: 0,
},
{
name: '新疆',
confirm: 32,
suspect: 0,
heal: 0,
dead: 0,
},
{
name: '香港',
confirm: 18,
suspect: 0,
heal: 0,
dead: 1,
},
{
name: '青海',
confirm: 17,
suspect: 0,
heal: 3,
dead: 0,
},
{
name: '台湾',
confirm: 11,
suspect: 0,
heal: 0,
dead: 0,
},
{
name: '澳门',
confirm: 10,
suspect: 0,
heal: 0,
dead: 0,
},
{
name: '西藏',
confirm: 1,
suspect: 0,
heal: 0,
dead: 0,
},
];
scene.on('loaded', () => {
const Layer = new CountryLayer(scene, {
data,
depth: 1,
fill: {
scale: 'quantile',
field: 'confirm',
values: [
'#feedde',
'#fdd0a2',
'#fdae6b',
'#fd8d3c',
'#e6550d',
'#a63603',
],
},
});
});
this.scene = scene;
const scene2 = new Scene({
id: 'map2',
logoVisible: false,
map: new Mapbox({
center: [113.60540108435657, 12.833692637803168],
pitch: 0,
style: 'blank',
zoom: 1.93,
minZoom: 0,
maxZoom: 3,
interactive: false,
}),
});
scene2.on('loaded', () => {
const Layer2 = new CountryLayer(scene2, {
data,
label: {
enable: false,
},
popup: {
enable: false,
},
autoFit: false,
fill: {
scale: 'quantile',
field: 'confirm',
values: [
'#feedde',
'#fdd0a2',
'#fdae6b',
'#fd8d3c',
'#e6550d',
'#a63603',
],
},
});
});
}
public render() {
return (
<>
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
/>
<div
id="map2"
style={{
position: 'absolute',
height: '125px',
width: '98px',
right: '100px',
bottom: '20px',
border: '1px solid #333',
}}
/>
</>
);
}
}

View File

@ -0,0 +1,64 @@
import { Scene } from '@antv/l7';
import { CountryLayer } from '@antv/l7-district';
import { GaodeMap, Mapbox } from '@antv/l7-maps';
import * as React from 'react';
export default class Country extends React.Component {
// @ts-ignore
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const scene = new Scene({
id: 'map',
map: new Mapbox({
center: [116.2825, 39.9],
pitch: 0,
style: 'blank',
zoom: 3,
minZoom: 3,
maxZoom: 10,
}),
});
scene.on('loaded', () => {
const Layer = new CountryLayer(scene, {
data: [],
depth: 2,
stroke: '#fff',
coastlineWidth: 0.5,
nationalWidth: 0.5,
fill: {
// scale: 'quantile',
field: 'name',
values: [
'#feedde',
'#fdd0a2',
'#fdae6b',
'#fd8d3c',
'#e6550d',
'#a63603',
],
},
});
});
this.scene = scene;
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
/>
);
}
}

View File

@ -0,0 +1,69 @@
import { Scene } from '@antv/l7';
import { CountryLayer } from '@antv/l7-district';
import { GaodeMap, Mapbox } from '@antv/l7-maps';
import * as React from 'react';
export default class Country extends React.Component {
// @ts-ignore
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const scene = new Scene({
id: 'map',
map: new Mapbox({
center: [116.2825, 39.9],
pitch: 0,
style: 'blank',
zoom: 3,
minZoom: 3,
maxZoom: 10,
}),
});
scene.on('loaded', () => {
const Layer = new CountryLayer(scene, {
data: [],
depth: 3,
stroke: '#fff',
coastlineWidth: 0.5,
nationalWidth: 0.5,
fill: {
// scale: 'quantile',
field: 'NAME',
values: [
'#feedde',
'#fdd0a2',
'#fdae6b',
'#fd8d3c',
'#e6550d',
'#a63603',
],
},
popup: {
Html: (props) => {
return `<span>${props.NAME}</span>`;
},
},
});
});
this.scene = scene;
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
/>
);
}
}

View File

@ -0,0 +1,64 @@
import { Scene } from '@antv/l7';
import { WorldLayer } from '@antv/l7-district';
import { GaodeMap, Mapbox } from '@antv/l7-maps';
import * as React from 'react';
export default class Country extends React.Component {
// @ts-ignore
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const scene = new Scene({
id: 'map',
map: new Mapbox({
center: [116.2825, 39.9],
pitch: 0,
style: 'blank',
zoom: 0,
minZoom: 0,
maxZoom: 10,
}),
});
scene.on('loaded', () => {
const Layer = new WorldLayer(scene, {
data: [],
fill: {
field: 'Short_Name_ZH',
values: [
'#feedde',
'#fdd0a2',
'#fdae6b',
'#fd8d3c',
'#e6550d',
'#a63603',
],
},
stroke: '#ccc',
label: {
textAllowOverlap: false,
field: 'Short_Name_ZH',
},
});
});
this.scene = scene;
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
/>
);
}
}

View File

@ -1,7 +1,14 @@
import { storiesOf } from '@storybook/react';
import * as React from 'react';
import Country from './Layer/Country';
import Country2 from './Layer/Country2';
import CountryCity from './Layer/country_city';
import CountryCounty from './Layer/country_county';
import World from './Layer/world';
storiesOf('行政区划', module)
.add('中国地图', () => <Country />);
.add('世界地图', () => <World />)
.add('中国地图', () => <Country />)
.add('中国地图市级', () => <CountryCity />)
.add('中国地图县级', () => <CountryCounty />)
.add('中国地图附图', () => <Country2 />);

View File

@ -5906,6 +5906,11 @@ array-reduce@~0.0.0:
resolved "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b"
integrity sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys=
array-source@0.0:
version "0.0.4"
resolved "https://registry.npmjs.org/array-source/-/array-source-0.0.4.tgz#a525df4a84b1376d27c677cd426a97c3882f8aca"
integrity sha512-frNdc+zBn80vipY+GdcJkLEbMWj3xmzArYApmUGxoiV8uAu/ygcs9icPdsGdA26h0MkHUMW6EN2piIvVx+M5Mw==
array-tree-filter@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/array-tree-filter/-/array-tree-filter-2.1.0.tgz#873ac00fec83749f255ac8dd083814b4f6329190"
@ -11256,6 +11261,13 @@ file-name@^0.1.0:
resolved "https://registry.npmjs.org/file-name/-/file-name-0.1.0.tgz#12b122f120f9c34dbc176c1ab81a548aced6def7"
integrity sha1-ErEi8SD5w028F2wauBpUis7W3vc=
file-source@0.6:
version "0.6.1"
resolved "https://registry.npmjs.org/file-source/-/file-source-0.6.1.tgz#ae189d4993766b865a77f83adcf9b9a504cd37dc"
integrity sha1-rhidSZN2a4Zad/g63Pm5pQTNN9w=
dependencies:
stream-source "0.3"
file-system-cache@^1.0.5:
version "1.0.5"
resolved "https://registry.npmjs.org/file-system-cache/-/file-system-cache-1.0.5.tgz#84259b36a2bbb8d3d6eb1021d3132ffe64cfff4f"
@ -12410,6 +12422,15 @@ gensync@^1.0.0-beta.1:
resolved "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz#58f4361ff987e5ff6e1e7a210827aa371eaac269"
integrity sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg==
geobuf@^3.0.1:
version "3.0.1"
resolved "https://registry.npmjs.org/geobuf/-/geobuf-3.0.1.tgz#1de4376f1d270c87ea7551a12b857cf89ae777ad"
integrity sha512-6gwj0B9oJaOVcG1HFliN/nmsUFq4FRlVmMKyykQ7lV574PeRHJH6ByB7HZtwztpDzJc8RJHUQhH5jH7Sg6EYvA==
dependencies:
concat-stream "^1.6.2"
pbf "^3.1.0"
shapefile "~0.6.6"
geojson-equality@0.1.6:
version "0.1.6"
resolved "https://registry.npmjs.org/geojson-equality/-/geojson-equality-0.1.6.tgz#a171374ef043e5d4797995840bae4648e0752d72"
@ -18813,6 +18834,14 @@ path-parse@^1.0.6:
resolved "https://registry.npmjs.org/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c"
integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw==
path-source@0.1:
version "0.1.3"
resolved "https://registry.npmjs.org/path-source/-/path-source-0.1.3.tgz#03907c595480aa2596a15a901c44f745736e7a73"
integrity sha512-dWRHm5mIw5kw0cs3QZLNmpUWty48f5+5v9nWD2dw3Y0Hf+s01Ag8iJEWV0Sm0kocE8kK27DrIowha03e1YR+Qw==
dependencies:
array-source "0.0"
file-source "0.6"
path-to-regexp@0.1.7:
version "0.1.7"
resolved "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"
@ -18846,7 +18875,7 @@ path-type@^4.0.0:
resolved "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b"
integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==
pbf@^3.0.5, pbf@^3.2.1:
pbf@^3.0.5, pbf@^3.1.0, pbf@^3.2.1:
version "3.2.1"
resolved "https://registry.npmjs.org/pbf/-/pbf-3.2.1.tgz#b4c1b9e72af966cd82c6531691115cc0409ffe2a"
integrity sha512-ClrV7pNOn7rtmoQVF4TS1vyU0WhYRnP92fzbfF75jAIwpnzdJXf8iTd4CMEqO4yUenH6NDqLiwjqlh6QgZzgLQ==
@ -22375,6 +22404,18 @@ shallowequal@^1.0.2, shallowequal@^1.1.0:
resolved "https://registry.npmjs.org/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8"
integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==
shapefile@~0.6.6:
version "0.6.6"
resolved "https://registry.npmjs.org/shapefile/-/shapefile-0.6.6.tgz#6fee152b9fb2b1c85f690285b692fb68c95a5f4f"
integrity sha512-rLGSWeK2ufzCVx05wYd+xrWnOOdSV7xNUW5/XFgx3Bc02hBkpMlrd2F1dDII7/jhWzv0MSyBFh5uJIy9hLdfuw==
dependencies:
array-source "0.0"
commander "2"
path-source "0.1"
slice-source "0.4"
stream-source "0.3"
text-encoding "^0.6.4"
sharkdown@^0.1.0:
version "0.1.1"
resolved "https://registry.npmjs.org/sharkdown/-/sharkdown-0.1.1.tgz#64484bd0f08f347f8319e9ff947a670f6b48b1b2"
@ -22607,6 +22648,11 @@ slice-ansi@^3.0.0:
astral-regex "^2.0.0"
is-fullwidth-code-point "^3.0.0"
slice-source@0.4:
version "0.4.1"
resolved "https://registry.npmjs.org/slice-source/-/slice-source-0.4.1.tgz#40a57ac03c6668b5da200e05378e000bf2a61d79"
integrity sha1-QKV6wDxmaLXaIA4FN44AC/KmHXk=
slick-carousel@^1.8.1:
version "1.8.1"
resolved "https://registry.npmjs.org/slick-carousel/-/slick-carousel-1.8.1.tgz#a4bfb29014887bb66ce528b90bd0cda262cc8f8d"
@ -23139,6 +23185,11 @@ stream-shift@^1.0.0:
resolved "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d"
integrity sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ==
stream-source@0.3:
version "0.3.5"
resolved "https://registry.npmjs.org/stream-source/-/stream-source-0.3.5.tgz#b97f52d0f8ea566db071db679b985403a31e0340"
integrity sha512-ZuEDP9sgjiAwUVoDModftG0JtYiLUV8K4ljYD1VyUMRWtbVf92474o4kuuul43iZ8t/hRuiDAx1dIJSvirrK/g==
strict-uri-encode@^1.0.0:
version "1.1.0"
resolved "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz#279b225df1d582b1f54e65addd4352e18faa0713"
@ -24008,6 +24059,11 @@ test-exclude@^5.2.3:
read-pkg-up "^4.0.0"
require-main-filename "^2.0.0"
text-encoding@^0.6.4:
version "0.6.4"
resolved "https://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19"
integrity sha1-45mpgiV6J22uQou5KEXLcb3CbRk=
text-extensions@^1.0.0:
version "1.9.0"
resolved "https://registry.npmjs.org/text-extensions/-/text-extensions-1.9.0.tgz#1853e45fee39c945ce6f6c36b2d659b5aabc2a26"