Merge pull request #65 from antvis/site

docs(docs): add api
This commit is contained in:
@thinkinggis 2019-11-21 10:14:09 +08:00 committed by GitHub
commit da1bb3b1b2
136 changed files with 4607 additions and 26281 deletions

56
.cache/redirects.json Normal file
View File

@ -0,0 +1,56 @@
[
{
"fromPath": "/en/docs/api",
"isPermanent": true,
"redirectInBrowser": true,
"toPath": "/en/docs/api/L7"
},
{
"fromPath": "/zh/docs/api",
"isPermanent": true,
"redirectInBrowser": true,
"toPath": "/zh/docs/api/L7"
},
{
"fromPath": "/zh/docs/tutorial",
"isPermanent": true,
"redirectInBrowser": true,
"toPath": "/zh/docs/api/quickstart"
},
{
"fromPath": "/en/docs/tutorial",
"isPermanent": true,
"redirectInBrowser": true,
"toPath": "/en/docs/api/quickstart"
},
{
"fromPath": "/zh/examples/raster/",
"isPermanent": true,
"redirectInBrowser": true,
"toPath": "/zh/examples/raster/basic"
},
{
"fromPath": "/zh/examples/polygon/",
"isPermanent": true,
"redirectInBrowser": true,
"toPath": "/zh/examples/polygon/3d"
},
{
"fromPath": "/zh/examples/heatmap/",
"isPermanent": true,
"redirectInBrowser": true,
"toPath": "/zh/examples/heatmap/heatmap"
},
{
"fromPath": "/en/examples",
"isPermanent": true,
"redirectInBrowser": true,
"toPath": "/en/examples/gallery/basic"
},
{
"fromPath": "/zh/examples",
"isPermanent": true,
"redirectInBrowser": true,
"toPath": "/zh/examples/gallery/basic"
}
]

BIN
.cache/redux.state Normal file

Binary file not shown.

View File

@ -1,5 +1,45 @@
{ {
"extends": [
"eslint-config-egg"
],
"globals": { "globals": {
"AMap": true "AMap": true,
"L7": true,
},
"env": {
"browser": true,
"node": true
},
"parser": "babel-eslint",
"parserOptions": {
"sourceType": "module"
},
"plugins": [
"html"
],
"rules": {
"no-console": [
"error",
{
"allow": [
"warn",
"error"
]
}
],
"no-bitwise": [
0
],
"experimentalDecorators": [
0
],
"comma-dangle": [
"error",
"never"
],
"jsdoc/require-param": 0,
"linebreak-style": [
0
]
} }
} }

View File

@ -5,6 +5,8 @@ node_js:
branches: branches:
only: only:
- next - next
install:
- yarn install
script: script:
- yarn test - yarn test
- yarn coveralls - yarn coveralls

View File

@ -1,8 +1,5 @@
# L7 # L7
[![版本](https://badgen.net/npm/v/@antv/l7)](https://www.npmjs.com/@antv/l7)
[![NPM downloads](http://img.shields.io/npm/dm/@antv/l7.svg)](http://npmjs.com/@antv/l7)
![最近提交](https://badgen.net/github/last-commit/antvis/L7) ![最近提交](https://badgen.net/github/last-commit/antvis/L7)
L7 Large-scale WebGL-powered Geospatial data visualization analysis framework L7 Large-scale WebGL-powered Geospatial data visualization analysis framework
@ -11,7 +8,7 @@ L7 Large-scale WebGL-powered Geospatial data visualization analysis framework
### Installation ### Installation
``` ```
npm install @l7/l7 npm install @antv/l7
``` ```

125
README.zh.md Normal file
View File

@ -0,0 +1,125 @@
## L7 地理空间数据可视分析引擎
L7 是由蚂蚁金服 AntV 数据可视化团队推出的基于 WebGL 的开源大规模地理空间数据可视分析开发框架。L7 中的 L 代表 Location7 代表世界七大洲寓意能为全球位置数据提供可视分析的能力。L7 以图形符号学为理论基础,将抽象复杂的空间数据转化成 2D、3D 符号,通过颜色、大小、体积、纹理等视觉变量实现丰富的可视化表达。
<video id="video" controls="" preload="none" poster="https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*rjkiQLCoZxUAAAAAAAAAAABkARQnAQ">
<source id="mp4" src="https://gw.alipayobjects.com/mdn/antv_site/afts/file/A*viKwSJl2OGIAAAAAAAAAAABkARQnAQ"; type="video/map4">
<source id="webm" src="https://gw.alipayobjects.com/os/basement_prod/65d5dbe8-d78d-4c6b-9318-fa06b1456784.webm" type="video/webm">
<source id="ogv" src="http://media.w3.org/2010/05/sintel/trailer.ogv" type="video/ogg">
<p>Your user agent does not support the HTML5 Video element.</p>
</video>
### Installation
```
npm install @antv/l7
```
## 核心特性
### 🌏 数据驱动可视化展示
数据驱动,从数到形,支持丰富的地图可视化类型,更好洞察数据。
### 🌏 2D3D 一体化的海量数据高性能渲染
百万级空间数据实时,动态渲染。
### 🌏简单灵活的数据接入
支持CSVJSONgeojson等数据格式接入可以根据需求自定义数据格式无需复杂的空间数据转换。
### 🌏 多地图底图支持,支持离线内网部署
高德地图国内合法合规的地理底图Mapbox 满足国际化业务需求。
## 支持丰富的图表类型
### 点图层
- 气泡图
- 散点图
- 符号地图
- 3D柱状地图
- 聚合地图
- 复合图表地图
- 自定义Marker
### 线图层
- 路径地图
- 弧线支持2D弧线、3D弧线以及大圆航线
- 等值线
### 面图层
- 填充图
- 3D填充图
### 热力图
- 经典热力图
- 蜂窝热力图
- 网格热力图
### 栅格地图
- 图片
- Raster
## L7 2.0 Roadmap
![L7 Road Map](https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*3j9HTLTQT2MAAAAAAAAAAABkARQnAQ)
## Development
使用 Yarn Workspace 完成依赖安装以及各包之间的 link 工作:
```bash
yarn install
```
开发模式:
```bash
yarn watch
```
运行 Demo
```bash
yarn storybook
```
代替 `git commit` 提交:
```bash
yarn commit
```
## view doc example
```bash
npm start
```
visit http://localhost:8000/
## Add Package
add new package
```bash
lerna create my-pack -y
```
将 ui-lib 作为 my-pack 的依赖:
```bash
yarn workspace my-pack add ui-lib/1.0.0
```
将 lodash 添加为所有 package 的依赖(不包含root
```bash
yarn workspaces run add lodash
```
将 typescript 设置为 root 的开发依赖
```bash
yarn add -W -D typescript jest
```

View File

@ -1,5 +1,5 @@
// @see https://babeljs.io/docs/en/next/config-files#project-wide-configuration // @see https://babeljs.io/docs/en/next/config-files#project-wide-configuration
module.exports = (api) => { module.exports = api => {
api.cache(() => process.env.NODE_ENV); api.cache(() => process.env.NODE_ENV);
const isSite = api.env('site'); const isSite = api.env('site');
@ -10,16 +10,16 @@ module.exports = (api) => {
if (isSite) { // if (isSite) { //
return { return {
"presets": [ presets: [
"babel-preset-gatsby" 'babel-preset-gatsby'
], ],
"plugins": [ plugins: [
'@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator', '@babel/plugin-proposal-nullish-coalescing-operator',
[ [
'@babel/plugin-proposal-decorators', '@babel/plugin-proposal-decorators',
{ {
legacy: true, legacy: true
} }
], ],
[ [
@ -29,10 +29,10 @@ module.exports = (api) => {
extensions: [ extensions: [
// 由于使用了 TS 的 resolveJsonModule 选项JSON 可以直接引入,不需要当作纯文本 // 由于使用了 TS 的 resolveJsonModule 选项JSON 可以直接引入,不需要当作纯文本
// '.json', // '.json',
'.glsl', '.glsl'
] ]
} }
], ]
] ]
}; };
} }
@ -43,20 +43,20 @@ module.exports = (api) => {
{ {
targets: { targets: {
browsers: 'Last 2 Chrome versions, Firefox ESR', browsers: 'Last 2 Chrome versions, Firefox ESR',
node: 'current', node: 'current'
}, },
// set `modules: false` when building CDN bundle, let rollup do commonjs works // set `modules: false` when building CDN bundle, let rollup do commonjs works
// @see https://github.com/rollup/rollup-plugin-babel#modules // @see https://github.com/rollup/rollup-plugin-babel#modules
modules: (isCDNBundle || isESModule) ? false : 'auto', modules: (isCDNBundle || isESModule) ? false : 'auto'
}, }
], ],
[ [
'@babel/preset-react', '@babel/preset-react',
{ {
development: isCommonJS, development: isCommonJS
}, }
], ],
'@babel/preset-typescript', '@babel/preset-typescript'
], ],
plugins: [ plugins: [
'@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-optional-chaining',
@ -64,14 +64,14 @@ module.exports = (api) => {
[ [
'@babel/plugin-proposal-decorators', '@babel/plugin-proposal-decorators',
{ {
legacy: true, legacy: true
} }
], ],
[ [
'@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-class-properties',
{ {
// @see https://github.com/storybookjs/storybook/issues/6069#issuecomment-472544973 // @see https://github.com/storybookjs/storybook/issues/6069#issuecomment-472544973
loose: true, loose: true
} }
], ],
'@babel/plugin-syntax-dynamic-import', '@babel/plugin-syntax-dynamic-import',
@ -87,7 +87,7 @@ module.exports = (api) => {
extensions: [ extensions: [
// 由于使用了 TS 的 resolveJsonModule 选项JSON 可以直接引入,不需要当作纯文本 // 由于使用了 TS 的 resolveJsonModule 选项JSON 可以直接引入,不需要当作纯文本
// '.json', // '.json',
'.glsl', '.glsl'
] ]
} }
], ],
@ -95,13 +95,13 @@ module.exports = (api) => {
// @see https://github.com/babel/babel/issues/8741#issuecomment-509041135 // @see https://github.com/babel/babel/issues/8741#issuecomment-509041135
'const-enum', 'const-enum',
{ {
transform: 'constObject', transform: 'constObject'
} }
], ],
// 按需引用 @see https://github.com/lodash/babel-plugin-lodash // 按需引用 @see https://github.com/lodash/babel-plugin-lodash
'lodash', 'lodash',
// 内联 WebGL 常量 @see https://www.npmjs.com/package/babel-plugin-inline-webgl-constants // 内联 WebGL 常量 @see https://www.npmjs.com/package/babel-plugin-inline-webgl-constants
isCDNBundle ? 'inline-webgl-constants' : {}, isCDNBundle ? 'inline-webgl-constants' : {}
], ],
ignore: [ ignore: [
'node_modules', 'node_modules',
@ -113,8 +113,8 @@ module.exports = (api) => {
'__tests__', '__tests__',
'__stories__', '__stories__',
'**/*/__snapshots__', '**/*/__snapshots__',
'**/*/__tests__', '**/*/__tests__'
]: [], ] : []
], ]
}; };
} };

View File

@ -2,3 +2,6 @@
export * from '@l7/scene'; export * from '@l7/scene';
// @ts-ignore // @ts-ignore
export * from '@l7/layers'; export * from '@l7/layers';
// @ts-ignore
export * from '@l7/component';

View File

@ -1,5 +1,5 @@
module.exports = { module.exports = {
extends: [ extends: [
"@commitlint/config-conventional" '@commitlint/config-conventional'
] ]
}; };

View File

@ -2,5 +2,74 @@
title: Introduction title: Introduction
order: 0 order: 0
redirect_from: redirect_from:
- /en/docs/api/ - /en/docs/api
--- ---
#### An open source large-scale geospatial data visualization analysis development framework powered by WebGL
L7 是由蚂蚁金服 AntV 数据可视化团队推出的基于 WebGL 的开源大规模地理空间数据可视分析开发框架。L7 中的 L 代表 Location7 代表世界七大洲寓意能为全球位置数据提供可视分析的能力。L7 以图形符号学为理论基础,将抽象复杂的空间数据转化成 2D、3D 符号,通过颜色、大小、体积、纹理等视觉变量实现丰富的可视化表达。
<video id="video" controls="" preload="none" poster="https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*rjkiQLCoZxUAAAAAAAAAAABkARQnAQ">
<source id="mp4" src="https://gw.alipayobjects.com/mdn/antv_site/afts/file/A*viKwSJl2OGIAAAAAAAAAAABkARQnAQ"; type="video/map4">
<source id="webm" src="https://gw.alipayobjects.com/os/basement_prod/65d5dbe8-d78d-4c6b-9318-fa06b1456784.webm" type="video/webm">
<source id="ogv" src="http://media.w3.org/2010/05/sintel/trailer.ogv" type="video/ogg">
<p>Your user agent does not support the HTML5 Video element.</p>
</video>
## 核心特性
🌏 数据驱动可视化展示
数据驱动,从数到形,支持丰富的地图可视化类型,更好洞察数据。
🌏 2D3D 一体化的海量数据高性能渲染
百万级空间数据实时,动态渲染。
🌏 简单灵活的数据接入
支持CSVJSONgeojson等数据格式接入可以根据需求自定义数据格式无需复杂的空间数据转换。
🌏 多地图底图支持,支持离线内网部署
高德地图国内合法合规的地理底图Mapbox 满足国际化业务需求。
## 支持丰富的图表类型
### 点图层
- 气泡图
- 散点图
- 符号地图
- 3D柱状地图
- 聚合地图
- 复合图表地图
- 自定义Marker
### 线图层
- 路径地图
- 弧线支持2D弧线、3D弧线以及大圆航线
- 等值线
### 面图层
- 填充图
- 3D填充图
### 热力图
- 经典热力图
- 蜂窝热力图
- 网格热力图
### 栅格地图
- 图片
- Raster
## L7 2.0 Roadmap
![L7 Road Map](https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*3j9HTLTQT2MAAAAAAAAAAABkARQnAQ)
更多技术细节,详细进展,请关注 [GitHub](https://github.com/antvis/L7),欢迎大家来给点点 Star让更多人看到这个开源的项目。

View File

@ -2,5 +2,75 @@
title: 简介 title: 简介
order: 0 order: 0
redirect_from: redirect_from:
- /zh/docs/api/ - /zh/docs/api
--- ---
# L7 地理空间数据可视分析引擎
L7 是由蚂蚁金服 AntV 数据可视化团队推出的基于 WebGL 的开源大规模地理空间数据可视分析开发框架。L7 中的 L 代表 Location7 代表世界七大洲寓意能为全球位置数据提供可视分析的能力。L7 以图形符号学为理论基础,将抽象复杂的空间数据转化成 2D、3D 符号,通过颜色、大小、体积、纹理等视觉变量实现丰富的可视化表达。
<video id="video" controls="" preload="none" poster="https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*rjkiQLCoZxUAAAAAAAAAAABkARQnAQ">
<source id="mp4" src="https://gw.alipayobjects.com/mdn/antv_site/afts/file/A*viKwSJl2OGIAAAAAAAAAAABkARQnAQ"; type="video/map4">
<source id="webm" src="https://gw.alipayobjects.com/os/basement_prod/65d5dbe8-d78d-4c6b-9318-fa06b1456784.webm" type="video/webm">
<source id="ogv" src="http://media.w3.org/2010/05/sintel/trailer.ogv" type="video/ogg">
<p>Your user agent does not support the HTML5 Video element.</p>
</video>
## 核心特性
🌏 数据驱动可视化展示
数据驱动,从数到形,支持丰富的地图可视化类型,更好洞察数据。
🌏 2D3D 一体化的海量数据高性能渲染
百万级空间数据实时,动态渲染。
🌏 简单灵活的数据接入
支持CSVJSONgeojson等数据格式接入可以根据需求自定义数据格式无需复杂的空间数据转换。
🌏 多地图底图支持,支持离线内网部署
高德地图国内合法合规的地理底图Mapbox 满足国际化业务需求。
## 支持丰富的图表类型
### 点图层
- 气泡图
- 散点图
- 符号地图
- 3D柱状地图
- 聚合地图
- 复合图表地图
- 自定义Marker
### 线图层
- 路径地图
- 弧线支持2D弧线、3D弧线以及大圆航线
- 等值线
### 面图层
- 填充图
- 3D填充图
### 热力图
- 经典热力图
- 蜂窝热力图
- 网格热力图
### 栅格地图
- 图片
- Raster
## L7 2.0 Roadmap
![L7 Road Map](https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*3j9HTLTQT2MAAAAAAAAAAABkARQnAQ)
更多技术细节,详细进展,请关注 [GitHub](https://github.com/antvis/L7),欢迎大家来给点点 Star让更多人看到这个开源的项目。

View File

@ -1,10 +1,26 @@
--- ---
title: Scene title: 场景 Scene
order: 1 order: 1
--- ---
## 简介 # 简介
`Scene `基础的地图类,提供地图创建,图层创建,管理等功能
## Scene
L7 地理可视化 地图图层组件以及可视化所需要的资源如图片字体通过Scene统一管理
## Map
L7 地理可视化侧重于地理数据的可视化表达地图层需要依赖第三方地图第三方地图通过Scene 统一创建,创建管理
只需要通过Scene传入地图配置项即可。
目前L7 支持两种地图底图
- 高德地图 国内业务场景 合规中国地图
- MapBox 国际业务,或者内网离线部署场景
示例代码 示例代码
@ -21,49 +37,12 @@ const scene =new L7.Scene({
### 构造函数 ### 构造函数
**Scene**<br />支持两种实例化方式 **Scene**
- 独立实例化 内部根据id自动穿件地图实例
- 传入地图实例
#### 独立实例化 Scene
```javascript
const scene = new L7.Scene({
id: 'map',
mapStyle: 'dark',
center: [ 120.19382669582967, 30.258134 ],
pitch: 0,
zoom: 12,
maxZoom:20,
minZoom:0,
});
```
#### 根据map 实例创建Sence
_L7 基于高德地图3D模式开发的因此传入Map实例 __viewModes需要设置成3d_<br />_
```javascript
var mapinstance = new AMap.Map('map',{
center: [ 120.19382669582967, 30.258134 ],
viewMode: '3D',
pitch: 0,
zoom: 12,
maxZoom:20,
minZoom:0,
});
const scene = new L7.Scene({
mapStyle: 'dark',
map:mapinstance
});
```
## map ## map
L7 在scene 下保留了高德地图实例可以通过scene.map 调用高德地图的map方法。<br />map 实例方法见[高德地图文档](https://lbs.amap.com/api/javascript-api/reference/map) L7 在scene 下保留了高德地图实例可以通过scene.map 调用高德地图的map方法。<br />map 实例方法见[高德地图文档](https://lbs.amap.com/api/javascript-api/reference/map)
@ -72,24 +51,10 @@ L7 在scene 下保留了高德地图实例可以通过scene.map 调用高德
scene.map scene.map
``` ```
## 构造类
### PointLayer
新建点图层
### PolylineLayer
新建线图层
### PolygonLayer
新建面图层
### ImageLayer
新建图片图层
## 配置项 ## 配置项
### 地图配置项
### id ### id
需传入 dom 容器或者容器 id  {domObject || string} [必选] 需传入 dom 容器或者容器 id  {domObject || string} [必选]
@ -104,6 +69,12 @@ scene.map
地图初始俯仰角度 {number}  default 0 地图初始俯仰角度 {number}  default 0
### mapSyle ### mapSyle
简化地图样式设置L7 内置了三种主题默认样式
- dark
- light
- normal
地图样式 {style} 目前仅支持高德地图。 default 'dark'<br />L7 内置三种种默认地图样式 dark | light|blank 空地图 地图样式 {style} 目前仅支持高德地图。 default 'dark'<br />L7 内置三种种默认地图样式 dark | light|blank 空地图
设置地图的显示样式,目前支持两种地图样式:<br />第一种:自定义地图样式,如`"amap://styles/d6bf8c1d69cea9f5c696185ad4ac4c86"`<br />可前往[地图自定义平台](https://lbs.amap.com/dev/mapstyle/index)定制自己的个性地图样式;<br />第二种:官方样式模版,如`"amap://styles/grey"`。<br />其他模版样式及自定义地图的使用说明见[开发指南](https://lbs.amap.com/api/javascript-api/guide/create-map/mapstye/) 设置地图的显示样式,目前支持两种地图样式:<br />第一种:自定义地图样式,如`"amap://styles/d6bf8c1d69cea9f5c696185ad4ac4c86"`<br />可前往[地图自定义平台](https://lbs.amap.com/dev/mapstyle/index)定制自己的个性地图样式;<br />第二种:官方样式模版,如`"amap://styles/grey"`。<br />其他模版样式及自定义地图的使用说明见[开发指南](https://lbs.amap.com/api/javascript-api/guide/create-map/mapstye/)

View File

@ -1,5 +1,5 @@
--- ---
title: Map Control title: Control
order: 1 order: 1
--- ---
# control # control
@ -15,6 +15,7 @@ const baseControl = new L7.Control.Base(option);
#### option #### option
 position: `string` 控件位置支持是个方位 `bottomright, topright, bottomleft, topleft`  position: `string` 控件位置支持是个方位 `bottomright, topright, bottomleft, topleft`

View File

@ -1,5 +1,5 @@
--- ---
title: 地图组件 title: Control
order: 3 order: 3
--- ---
# control # control

View File

@ -1,5 +1,5 @@
--- ---
title: Map Marker title: Marker
order: 3 order: 3
--- ---

View File

@ -1,5 +1,5 @@
--- ---
title: 地图标注 title: Marker
order: 3 order: 3
--- ---

View File

@ -1,5 +1,5 @@
--- ---
title: 地图信息框 title: popup
order: 0 order: 0
--- ---
# popup # popup

View File

@ -1,4 +0,0 @@
---
title: Map Layer
order: 2
---

View File

@ -1,4 +0,0 @@
---
title: 图层
order: 2
---

View File

@ -0,0 +1,205 @@
---
title: HeatmapLayer
order: 5
---
# heatmapLayer
### 简介
热力图图层,包含三种类型的,
- 方格热力图
将一组点数据按照等大小的正方形网格进行聚合,一个正方形网格代表网格内所有点的统计值。方格热力图特点以方格网布局。
- 六边形热力图
将一组点数据按照等大小的六边形网格进行聚合,一个六边形网格代表网格内所有点的统计值。蜂窝热力图特点以六边形热力图网格布局
- 经典热力图
⚠️ 网格热力图和蜂窝热力图需要对数据聚合处理使用之前需要在source方法设置数据聚合方法
### source
热力图只支持点数据作为数据源
布局方法 通过source的 tansforms属性配置
- type  数据聚合类型 grid、hexagon
- size  网格半径 单位 米
- field  聚合字段
- method 聚合方法  count,max,min,sum,mean5个统计维度
```javascript
layer.source(data, {
parser: {
type: 'csv',
x: 'lng',
y: 'lat'
},
transforms:[
{
type: 'grid',
size: 15000,
field:'v',
method:'sum'
}
],
}
```
### shape
不同类型热力图shape支持
| | 2D | 3d |
| --- | --- | --- |
| 网格格热力图 | circle,triangle,square,heaxgon | cylinder,triangleColumn,hexagonColum,squareColumn |
| 蜂窝热力图 | circle,triangle,square,heaxgon | circle,triangle,square,heaxgon |
| 普通热力图 | heatmap | heatmap |
热力图布局下只shape方法只支持常量的可视化。
```javascript
HeatmapLayer.shape('square');
HeatmapLayer.shape('hexagon');
// 默认类型可以不设置
```
### size
当前版本 shape 为gridhexagon不需要设置 size 映射
default 类型需要设置size映射 详细参数见[Size](https://www.yuque.com/antv/l7/layer#size)
**size(field,values) **
- field: 热力图权重字段
- values: 数据映射区间 热力图显示 [0, 1] 效果最佳
```javascript
HeatmapLayer.size ('field', [0, 1])
```
### color
default heatMap 类型不需设置 color映射
color 配置项同 [**color**](https://www.yuque.com/antv/l7/layer#color)
### style
grid hexagon 可以通过style 设置透明度
default热力图需要通过style配置参数热力图参数
- intensity   全局热力权重   推荐权重范围 1-5
- radius  热力半径单位像素
- rampColors 色带参数
- colors  颜色数组
- positions 数据区间
```javascript
HeatmapLayer.style({
intensity: 3,
radius: 20,
rampColors: {
colors: [ 'rgba(33,102,172,0.0)', 'rgb(103,169,207)', 'rgb(209,229,240)', 'rgb(253,219,199)', 'rgb(239,138,98)', 'rgb(178,24,43,1.0)' ],
positions: [ 0, 0.2, 0.4, 0.6, 0.8, 1.0 ]
}
})
```
### 完整代码示例
#### 普通热力图
```javascript
// 测试数据 url https://gw.alipayobjects.com/os/basement_prod/08c6ea00-dc5f-4bb0-b0b5-52bde5edf0a3.json
HeatmapLayer({
zIndex: 2
})
.source(data)
.size('mag', [ 0, 1 ]) // weight映射通道
.style({
intensity: 3,
radius: 20,
rampColors: {
colors: [ 'rgba(33,102,172,0.0)', 'rgb(103,169,207)', 'rgb(209,229,240)', 'rgb(253,219,199)', 'rgb(239,138,98)', 'rgb(178,24,43,1.0)' ],
positions: [ 0, 0.2, 0.4, 0.6, 0.8, 1.0 ]
}
})
```
#### 网格热力图
```javascript
var layer = scene.HeatmapLayer({
zIndex: 2
})
.source(data, {
parser: {
type: 'csv',
x: 'lng',
y: 'lat'
},
transforms:[
{
type: 'grid',
size: 15000,
field:'v',
method:'sum'
}
]
})
.shape('grid')
.style({
coverage: 0.8
})
.color('count',
["#002466","#105CB3","#2894E0","#CFF6FF","#FFF5B8","#FFAB5C","#F27049","#730D1C"])
```
#### 六边形热力图
```javascript
var layer = scene.HeatmapLayer({
zIndex: 2
}).
souce(data,{
parser:{
type:'csv',
x:lng,
y:lat,
},
transforms:[
{
type:'hexgon',
size:1500,
field:'count',
operation: 'sum',
}
]
})
.shape('hexgon')
.size(1000)
.color('sum')
.style({
coverage:0.8
})
render()
```

View File

@ -0,0 +1,204 @@
---
title: HeatmapLayer
order: 5
---
# heatmapLayer
### 简介
热力图图层,包含三种类型的,
- 方格热力图
将一组点数据按照等大小的正方形网格进行聚合,一个正方形网格代表网格内所有点的统计值。方格热力图特点以方格网布局。
- 六边形热力图
将一组点数据按照等大小的六边形网格进行聚合,一个六边形网格代表网格内所有点的统计值。蜂窝热力图特点以六边形热力图网格布局
- 经典热力图
⚠️ 网格热力图和蜂窝热力图需要对数据聚合处理使用之前需要在source方法设置数据聚合方法
### source
热力图只支持点数据作为数据源
布局方法 通过source的 tansforms属性配置
- type  数据聚合类型 grid、hexagon
- size  网格半径 单位 米
- field  聚合字段
- method 聚合方法  count,max,min,sum,mean5个统计维度
```javascript
layer.source(data, {
parser: {
type: 'csv',
x: 'lng',
y: 'lat'
},
transforms:[
{
type: 'grid',
size: 15000,
field:'v',
method:'sum'
}
],
}
```
### shape
不同类型热力图shape支持
| | 2D | 3d |
| --- | --- | --- |
| 网格格热力图 | circle,triangle,square,heaxgon | cylinder,triangleColumn,hexagonColum,squareColumn |
| 蜂窝热力图 | circle,triangle,square,heaxgon | circle,triangle,square,heaxgon |
| 普通热力图 | heatmap | heatmap |
热力图布局下只shape方法只支持常量的可视化。
```javascript
HeatmapLayer.shape('square');
HeatmapLayer.shape('hexagon');
// 默认类型可以不设置
```
### size
当前版本 shape 为gridhexagon不需要设置 size 映射
default 类型需要设置size映射 详细参数见[Size](https://www.yuque.com/antv/l7/layer#size)
**size(field,values) **
- field: 热力图权重字段
- values: 数据映射区间 热力图显示 [0, 1] 效果最佳
```javascript
HeatmapLayer.size ('field', [0, 1])
```
### color
default heatMap 类型不需设置 color映射
color 配置项同 [**color**](https://www.yuque.com/antv/l7/layer#color)
### style
grid hexagon 可以通过style 设置透明度
default热力图需要通过style配置参数热力图参数
- intensity   全局热力权重   推荐权重范围 1-5
- radius  热力半径单位像素
- rampColors 色带参数
- colors  颜色数组
- positions 数据区间
```javascript
HeatmapLayer.style({
intensity: 3,
radius: 20,
rampColors: {
colors: [ 'rgba(33,102,172,0.0)', 'rgb(103,169,207)', 'rgb(209,229,240)', 'rgb(253,219,199)', 'rgb(239,138,98)', 'rgb(178,24,43,1.0)' ],
positions: [ 0, 0.2, 0.4, 0.6, 0.8, 1.0 ]
}
})
```
### 完整代码示例
#### 普通热力图
```javascript
// 测试数据 url https://gw.alipayobjects.com/os/basement_prod/08c6ea00-dc5f-4bb0-b0b5-52bde5edf0a3.json
HeatmapLayer({
zIndex: 2
})
.source(data)
.size('mag', [ 0, 1 ]) // weight映射通道
.style({
intensity: 3,
radius: 20,
rampColors: {
colors: [ 'rgba(33,102,172,0.0)', 'rgb(103,169,207)', 'rgb(209,229,240)', 'rgb(253,219,199)', 'rgb(239,138,98)', 'rgb(178,24,43,1.0)' ],
positions: [ 0, 0.2, 0.4, 0.6, 0.8, 1.0 ]
}
})
```
#### 网格热力图
```javascript
var layer = scene.HeatmapLayer({
zIndex: 2
})
.source(data, {
parser: {
type: 'csv',
x: 'lng',
y: 'lat'
},
transforms:[
{
type: 'grid',
size: 15000,
field:'v',
method:'sum'
}
]
})
.shape('grid')
.style({
coverage: 0.8
})
.color('count',
["#002466","#105CB3","#2894E0","#CFF6FF","#FFF5B8","#FFAB5C","#F27049","#730D1C"])
```
#### 六边形热力图
```javascript
var layer = scene.HeatmapLayer({
zIndex: 2
}).
souce(data,{
parser:{
type:'csv',
x:lng,
y:lat,
},
transforms:[
{
type:'hexgon',
size:1500,
field:'count',
operation: 'sum',
},
],
})
.shape('hexgon')
.size(1000)
.color('sum')
.style({
coverage:0.8
})
render()
```

View File

@ -0,0 +1,23 @@
---
title: ImageLayer
order: 5
---
# ImageLayer
## 简介
将图片添加到地图上,需要指定图片的经纬度范围
### 代码示例
```javascript
const layer = new ImageLayer({});
layer.source(
'https://gw.alipayobjects.com/zos/rmsportal/FnHFeFklTzKDdUESRNDv.jpg',
{
parser: {
type: 'image',
extent: [ 121.168, 30.2828, 121.384, 30.4219 ]
}
}
);
```

View File

@ -0,0 +1,23 @@
---
title: ImageLayer
order: 5
---
# ImageLayer
## 简介
将图片添加到地图上,需要指定图片的经纬度范围
### 代码示例
```javascript
const layer = new ImageLayer({});
layer.source(
'https://gw.alipayobjects.com/zos/rmsportal/FnHFeFklTzKDdUESRNDv.jpg',
{
parser: {
type: 'image',
extent: [ 121.168, 30.2828, 121.384, 30.4219 ]
}
}
);
```

322
docs/API/layer/layer.en.md Normal file
View File

@ -0,0 +1,322 @@
---
title: Map Layer
order: 0
---
# Layer
## 简介
L7 Layer 接口设计遵循图形语法,在可视表达上
语法示例
```javascript
new Layer(option)
.source()
.color()
.size()
.shape()
.style()
```
## 构造函数
## 配置项
### visable
图层是否可见   {bool } default true
### zIndex
 图层绘制顺序,数值越小优先绘制,可以控制图层绘制的上下层级 {int}   default 0
### minZoom
图层显示最小缩放等级0-18   {number}  default 0
### maxZoom
 图层显示最大缩放等级 0-18   {number}  default 18
## 鼠标事件
beta版当前不支持正式版会支持
```javascript
layer.on('click', (ev)=>{}); // 鼠标左键点击图层事件
layer.on('dblclick', (ev)=>{}); // 鼠标左键双击图层事件
layer.on('mousemove', (ev)=>{}); // 鼠标在图层上移动时触发
layer.on('mouseover', (ev)=>{}); // 鼠标移入图层要素内时触发
layer.on('mouseout', (ev)=>{}); // 鼠标移出图层要素时触发
layer.on('mouseup', (ev)=>{}); // 鼠标在图层上单击抬起时触发
layer.on('mousedown', (ev)=>{}); // 鼠标在图层上单击按下时触发
layer.on('mouseleave', (ev)=>{}); // 鼠标离开图层要素
layer.on('rightclick', (ev)=>{}); // 鼠标右键图层要素
```
## 方法
### source
数据源为layer设置数据 source(data,config)
- data {geojson|json|csv}
      源数据
- config  可选 数据源配置项
- parser 数据解析默认是解析层geojson
- transforms [transformtransform ]  数据处理转换 可设置多个
 parser和 transforms [见source文档](https://www.yuque.com/antv/l7/source)
```javascript
layer.source(data, {
parser: {
type: 'csv',
x: 'lng',
y: 'lat'
},
transforms:[
{
type: 'map',
callback:function(item){
const [x, y] = item.coordinates;
item.lat = item.lat*1;
item.lng = item.lng*1;
item.v = item.v *1;
item.coordinates = [x*1,y*1];
return item;
}
},
{
type: 'hexagon',
size: 6000,
field:'v',
method:'sum'
}
]
})
```
###
### scale
cscle('field', scaleConfig)
(field: string, scaleConfig: object)
为指定的数据字段进行列定义,返回 layer 实例。
- `field` 字段名。
- `scaleConfig` 列定义配置,对象类型,可配置的属性如下:
```javascript
{
type: "linear" // 指定数据类型可声明的类型为identity、linear、cat、time、timeCat、log、pow, quantile,quantize
}
```
### size
将数据值映射到图形的大小上的方法。
**注意:** 
不同图层的 size 的含义有所差别:
- point 图形的 size 影响点的半径大小和高度;
- line, arc, path 中的 size 影响线的粗细,和高度;
- polygon size 影响的是高度
```javascript
pointLayer.size(10); // 常量
pointLayer.size('type'); // 使用字段映射到大小
pointLayer.size('type', [ 0, 10 ]); // 使用字段映射到大小,并指定最大值和最小值
pointLayer.size('type', (type) => { // 回调函数
if(type === 'a') {
return 10;
}
return 5;
});
```
#### size(value
传入数字常量,如 `pointLayer.size(20)`
#### size(field)
根据 field 字段的值映射大小,使用默认的`最大值 max:10` 和`最小值 min: 1`。
#### size(field, callback)
使用回调函数控制图形大小。
- `callback`: function 回调函数。
```javascript
pointLayer.size('age', (value) => {
if(value === 1) {
return 5;
}
return 10;
});
```
### color
将数据值映射到图形的颜色上的方法。
```javascript
layer.color('red'); // 常量颜色
layer.color('type'); // 对 type 字段进行映射,使用内置的颜色
layer.color('type', [ 'red', 'blue' ]) // 指定颜色
layer.color('type', (type) => { // 通过回调函数
if (type === 'a') {
return 'red';
}
return 'blue';
});
layer.color('type*value', (type, value) => { //多个参数,通过回调函数
if (type === 'a' && value > 100) {
return 'red';
}
return 'blue';
});
```
#### color(value)
参数:`value` string
只支持接收一个参数value 可以是:
- 映射至颜色属性的数据源字段名,如果数据源中不存在这个字段名的话,则按照常量进行解析,这个时候会使用 L7 默认提供的颜色。
- 也可以直接指定某一个具体的颜色值 color如 '#fff', 'white','rgba(255,0,0,0.5)' ,rgb(255,0,1) 等。
示例
```javascript
layer.color('name') // 映射数据字段
layer.color('white') // 指定颜色
```
#### color(field, colors)
参数:
- `field`: stringfield 为映射至颜色属性的数据源字段名,也支持指定多个参数。
-  `colors`: string | array | function
colors 的参数有以下情况: 如果为空,即未指定颜色的数组,那么使用内置的全局的颜色;如果需要指定颜色,则需要以数组格式传入,那么分类的颜色按照数组中的颜色确定。对于颜色的分配顺序。
```javascript
layer.color('name'); // 使用默认的颜色
layer.color('name', [ 'red', 'blue' ]); // 使用传入的指定颜色
```
- colors 如果是回调函数,则该回调函数的参数为对应字段的数值,具体使用如下,当 color 映射为多个字段时,参数按照字段声明的顺序传入:
```javascript
layer.color('gender', (value) => {
if(value === 1) {
return 'red'
}
return 'blue';
});
layer.color('gender*age', (gender, age) => {
if(age === 20 && gender ==' 男' ) {
return 'red'
}
return 'blue';
});
```
### shape
将数据值映射到图形的形状上的方法。
**shape(shape)**
参数`shape` string
只支持接收一个参数,指定几何图像对象绘制的形状。下表列出了不同的 图层 几何图形对象支持的 shape 形状
| layer类型 | shape类型 | 备注 |
| --- | --- | --- |
| point | 2d:point,circle, square, triangle,hexagon,image,text 3d:circle,triangle,hexagon,square | |
| line | line,arc, arc3d, greatcircle | |
| polygon | fill,line, extrude | |
**shape(field, shapes)**
**shape(field, callback)**
### style
用于配置几何体显示图像属性目前支持以下属性,其他属性会逐步开放
- fill
- opacity  设置透明度
- stroke 线填充颜色
- strokeWidth 线的宽度
```javascript
layer.style({
fill:'red',
opacity:0.8,
stroke:'white'
})
```
### show
图层显示
```javascript
layer.show();
```
### hide
图层隐藏
```javascript
layer.hide();
```
### fitBounds
缩放到图层范围
```javascript
layer.fitBounds()
```

322
docs/API/layer/layer.zh.md Normal file
View File

@ -0,0 +1,322 @@
---
title: Layer
order: 0
---
# Layer
## 简介
L7 Layer 接口设计遵循图形语法,在可视表达上
语法示例
```javascript
new Layer(option)
.source()
.color()
.size()
.shape()
.style()
```
## 构造函数
## 配置项
### visable
图层是否可见   {bool } default true
### zIndex
 图层绘制顺序,数值越小优先绘制,可以控制图层绘制的上下层级 {int}   default 0
### minZoom
图层显示最小缩放等级0-18   {number}  default 0
### maxZoom
 图层显示最大缩放等级 0-18   {number}  default 18
## 鼠标事件
beta版当前不支持正式版会支持
```javascript
layer.on('click', (ev)=>{}); // 鼠标左键点击图层事件
layer.on('dblclick', (ev)=>{}); // 鼠标左键双击图层事件
layer.on('mousemove', (ev)=>{}); // 鼠标在图层上移动时触发
layer.on('mouseover', (ev)=>{}); // 鼠标移入图层要素内时触发
layer.on('mouseout', (ev)=>{}); // 鼠标移出图层要素时触发
layer.on('mouseup', (ev)=>{}); // 鼠标在图层上单击抬起时触发
layer.on('mousedown', (ev)=>{}); // 鼠标在图层上单击按下时触发
layer.on('mouseleave', (ev)=>{}); // 鼠标离开图层要素
layer.on('rightclick', (ev)=>{}); // 鼠标右键图层要素
```
## 方法
### source
数据源为layer设置数据 source(data,config)
- data {geojson|json|csv}
      源数据
- config  可选 数据源配置项
- parser 数据解析默认是解析层geojson
- transforms [transformtransform ]  数据处理转换 可设置多个
 parser和 transforms [见source文档](https://www.yuque.com/antv/l7/source)
```javascript
layer.source(data, {
parser: {
type: 'csv',
x: 'lng',
y: 'lat'
},
transforms:[
{
type: 'map',
callback:function(item){
const [x, y] = item.coordinates;
item.lat = item.lat*1;
item.lng = item.lng*1;
item.v = item.v *1;
item.coordinates = [x*1,y*1];
return item;
}
},
{
type: 'hexagon',
size: 6000,
field:'v',
method:'sum'
}
]
})
```
###
### scale
cscle('field', scaleConfig)
(field: string, scaleConfig: object)
为指定的数据字段进行列定义,返回 layer 实例。
- `field` 字段名。
- `scaleConfig` 列定义配置,对象类型,可配置的属性如下:
```javascript
{
type: "linear" // 指定数据类型可声明的类型为identity、linear、cat、time、timeCat、log、pow, quantile,quantize
}
```
### size
将数据值映射到图形的大小上的方法。
**注意:** 
不同图层的 size 的含义有所差别:
- point 图形的 size 影响点的半径大小和高度;
- line, arc, path 中的 size 影响线的粗细,和高度;
- polygon size 影响的是高度
```javascript
pointLayer.size(10); // 常量
pointLayer.size('type'); // 使用字段映射到大小
pointLayer.size('type', [ 0, 10 ]); // 使用字段映射到大小,并指定最大值和最小值
pointLayer.size('type', (type) => { // 回调函数
if(type === 'a') {
return 10;
}
return 5;
});
```
#### size(value
传入数字常量,如 `pointLayer.size(20)`
#### size(field)
根据 field 字段的值映射大小,使用默认的`最大值 max:10` 和`最小值 min: 1`。
#### size(field, callback)
使用回调函数控制图形大小。
- `callback`: function 回调函数。
```javascript
pointLayer.size('age', (value) => {
if(value === 1) {
return 5;
}
return 10;
});
```
### color
将数据值映射到图形的颜色上的方法。
```javascript
layer.color('red'); // 常量颜色
layer.color('type'); // 对 type 字段进行映射,使用内置的颜色
layer.color('type', [ 'red', 'blue' ]) // 指定颜色
layer.color('type', (type) => { // 通过回调函数
if (type === 'a') {
return 'red';
}
return 'blue';
});
layer.color('type*value', (type, value) => { //多个参数,通过回调函数
if (type === 'a' && value > 100) {
return 'red';
}
return 'blue';
});
```
#### color(value)
参数:`value` string
只支持接收一个参数value 可以是:
- 映射至颜色属性的数据源字段名,如果数据源中不存在这个字段名的话,则按照常量进行解析,这个时候会使用 L7 默认提供的颜色。
- 也可以直接指定某一个具体的颜色值 color如 '#fff', 'white','rgba(255,0,0,0.5)' ,rgb(255,0,1) 等。
示例
```javascript
layer.color('name') // 映射数据字段
layer.color('white') // 指定颜色
```
#### color(field, colors)
参数:
- `field`: stringfield 为映射至颜色属性的数据源字段名,也支持指定多个参数。
-  `colors`: string | array | function
colors 的参数有以下情况: 如果为空,即未指定颜色的数组,那么使用内置的全局的颜色;如果需要指定颜色,则需要以数组格式传入,那么分类的颜色按照数组中的颜色确定。对于颜色的分配顺序。
```javascript
layer.color('name'); // 使用默认的颜色
layer.color('name', [ 'red', 'blue' ]); // 使用传入的指定颜色
```
- colors 如果是回调函数,则该回调函数的参数为对应字段的数值,具体使用如下,当 color 映射为多个字段时,参数按照字段声明的顺序传入:
```javascript
layer.color('gender', (value) => {
if(value === 1) {
return 'red'
}
return 'blue';
});
layer.color('gender*age', (gender, age) => {
if(age === 20 && gender ==' 男' ) {
return 'red'
}
return 'blue';
});
```
### shape
将数据值映射到图形的形状上的方法。
**shape(shape)**
参数`shape` string
只支持接收一个参数,指定几何图像对象绘制的形状。下表列出了不同的 图层 几何图形对象支持的 shape 形状
| layer类型 | shape类型 | 备注 |
| --- | --- | --- |
| point | 2d:point,circle, square, triangle,hexagon,image,text 3d:circle,triangle,hexagon,square | |
| line | line,arc, arc3d, greatcircle | |
| polygon | fill,line, extrude | |
**shape(field, shapes)**
**shape(field, callback)**
### style
用于配置几何体显示图像属性目前支持以下属性,其他属性会逐步开放
- fill
- opacity  设置透明度
- stroke 线填充颜色
- strokeWidth 线的宽度
```javascript
layer.style({
fill:'red',
opacity:0.8,
stroke:'white'
})
```
### show
图层显示
```javascript
layer.show();
```
### hide
图层隐藏
```javascript
layer.hide();
```
### fitBounds
缩放到图层范围
```javascript
layer.fitBounds()
```

View File

@ -0,0 +1,72 @@
---
title: LineLayer
order: 2
---
## 线图层
### shape
线图层支持4种 shape
- line 绘制路径图,
- arc 绘制弧线 通过贝塞尔曲线算法技术弧线
- greatcircle 大圆航线,地图两个点的最近距离不是两个点连线,而是大圆航线
- arc3d 3d弧线地图 3D视角
⚠️ 弧线只需要设置起始点坐标即可
```
new LineLayer()
.source(data, {
parser: {
type: 'csv',
x: 'lng1',
y: 'lat1',
x1: 'lng2',
y1: 'lat2',
},
})
```
如果geojson 数据绘制弧线图 coordinates 第一对坐标为起点,第二对为终点
```
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
106.5234375,
57.51582286553883
],
[
136.40625,
61.77312286453146
]
]
}
}
]
}
```
### size
线图层 可以设置高度
- size 类型为number 则表示 line的宽度
- size 类型为 [number , number] 分别表示宽度和高度
```javascript
lineLayer.size(1); // 线的宽度为 1
lineLayer.size([1,2]); // 宽度为1高度2
```

View File

@ -0,0 +1,72 @@
---
title: LineLayer
order: 2
---
## 线图层
### shape
线图层支持4种 shape
- line 绘制路径图,
- arc 绘制弧线 通过贝塞尔曲线算法技术弧线
- greatcircle 大圆航线,地图两个点的最近距离不是两个点连线,而是大圆航线
- arc3d 3d弧线地图 3D视角
⚠️ 弧线只需要设置起始点坐标即可
```
new LineLayer()
.source(data, {
parser: {
type: 'csv',
x: 'lng1',
y: 'lat1',
x1: 'lng2',
y1: 'lat2',
},
})
```
如果geojson 数据绘制弧线图 coordinates 第一对坐标为起点,第二对为终点
```
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
106.5234375,
57.51582286553883
],
[
136.40625,
61.77312286453146
]
]
}
}
]
}
```
### size
线图层 可以设置高度
- size 类型为number 则表示 line的宽度
- size 类型为 [number , number] 分别表示宽度和高度
```javascript
lineLayer.size(1); // 线的宽度为 1
lineLayer.size([1,2]); // 宽度为1高度2
```

View File

@ -0,0 +1,77 @@
---
title: PointLayer
order: 1
---
# PointLayer
## 简介
点数据的展示数据源支持JSON,GeoJSON,CSV 三种数据格式。
shape 支持
**3D类型 柱图**
```
'cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn'
```
**2D 符号图**
```
'circle', 'square', 'hexagon', 'triangle' 'pentagon', 'octogon', 'hexagram','rhombus', 'vesica',
```
**图片标注**
通过 ```Scene.addImage()``` 可以添加图片资源,
### 代码示例
#### 基本图形显示示例
```javascript
import { PointLayer } from "@antv/l7"
const layer = PointLayer({
zIndex: 2
})
.source(data.list, {
type: 'array',
x: 'j',
y: 'w',
})
.shape('cylinder')
.size('t',(level)=> {
return [4,4,(level+40)];
})
.color('t', ["#002466","#105CB3","#2894E0","#CFF6FF","#FFF5B8","#FFAB5C","#F27049","#730D1C"])
```
#### 符号图
使用图片添加地图标注
```javascript
scene.addImage('local', 'https://gw.alipayobjects.com/zos/rmsportal/xZXhTxbglnuTmZEwqQrE.png');
const layer = new PointLayer({
zIndex: 4
})
.source(city)
.size(20.0)
.shape('local')
.color('#0D408C')
```

View File

@ -0,0 +1,78 @@
---
title: PointLayer
order: 1
---
# PointLayer
## 简介
点数据的展示数据源支持JSON,GeoJSON,CSV 三种数据格式。
shape 支持
**3D类型 柱图**
```
'cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn'
```
**2D 符号图**
```
'circle', 'square', 'hexagon', 'triangle' 'pentagon', 'octogon', 'hexagram','rhombus', 'vesica',
```
**图片标注**
通过 ```Scene.addImage()``` 可以添加图片资源,
### 代码示例
#### 基本图形显示示例
```javascript
import { PointLayer } from "@antv/l7"
const layer = PointLayer({
zIndex: 2
})
.source(data.list, {
type: 'array',
x: 'j',
y: 'w',
})
.shape('cylinder')
.size('t',(level)=> {
return [4,4,(level+40)];
})
.color('t', ["#002466","#105CB3","#2894E0","#CFF6FF","#FFF5B8","#FFAB5C","#F27049","#730D1C"])
```
#### 符号图
使用图片添加地图标注
```javascript
scene.addImage('local', 'https://gw.alipayobjects.com/zos/rmsportal/xZXhTxbglnuTmZEwqQrE.png');
const layer = new PointLayer({
zIndex: 4
})
.source(city)
.size(20.0)
.shape('local')
.color('#0D408C')
```

View File

@ -0,0 +1,26 @@
---
title: PolygonLayer
order: 3
---
# 填充图
绘制 2D 多边形以及沿 Z 轴拉伸后的 3D 图形。
### shape
填充图支持3种shape
- fill 绘制填充面 不支持数据映射
- line 绘制填充图描边 不支持数据映射
- extrude 对填充图3D拉伸 不支持数据映射
``` javascript
PolyonLayer.shape('fill');
PolyonLayer.shape('line').size(1); // size 表示线宽度
PolyonLayer.shape('extrude'); // size 表示高度
```
其他方法,事件,同基类 [Layer](/zh/docs/api/layer/layer)

View File

@ -0,0 +1,26 @@
---
title: PolygonLayer
order: 3
---
# 填充图
绘制 2D 多边形以及沿 Z 轴拉伸后的 3D 图形。
### shape
填充图支持3种shape
- fill 绘制填充面 不支持数据映射
- line 绘制填充图描边 不支持数据映射
- extrude 对填充图3D拉伸 不支持数据映射
``` javascript
PolyonLayer.shape('fill');
PolyonLayer.shape('line').size(1); // size 表示线宽度
PolyonLayer.shape('extrude'); // size 表示高度
```
其他方法,事件,同基类 [Layer](/zh/docs/api/layer/layer)

174
docs/API/quickstart.en.md Normal file
View File

@ -0,0 +1,174 @@
---
title: quickStart
order: 0
redirect_from:
- /en/docs/tutorial
---
# 使用方法
L7 提供三种使用方式CDN、Submodule 以及 React 组件。
## 通过 CDN 使用
首先在 `<head>` 中引入 L7 CDN 版本的 JS 和 CSS 文件:
```html
<head>
<script src='https://api.l7/v2.0.0-beta/l7.js'></script>
<link href='https://api.l7/v2.0.0-beta/l7.css' rel='stylesheet' />
</head>
```
如果使用 Mapbox还需要额外引入 Mapbox 的 JS 和 CSS 文件,这一步可以参考 [Mapbox 文档](https://docs.mapbox.com/mapbox-gl-js/overview/#quickstart)
```html
<head>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.5.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.5.0/mapbox-gl.css' rel='stylesheet' />
<!-- 上一步引入的 L7 JS 和 CSS -->
</head>
```
⚠️高德采用异步加载,因此不需要引入任何额外静态文件。
然后在 `<body>` 中定义一个容器并设置一个 `id`。通过全局 `L7` 这个命名空间可以获取场景 `L7.Scene` 和图层 `L7.PolygonLayer`
⚠️需要获取高德或者 Mapbox 的使用 token 并传入 `L7.Scene` 的构造函数,获取方式如下:
* 高德地图开发者 Key [申请方法](https://lbs.amap.com/dev/key/)
* [Mapbox Access Tokens](https://docs.mapbox.com/help/how-mapbox-works/access-tokens/#creating-and-managing-access-tokens)
## 通过 Submodule 使用
首先通过 `npm/yarn` 安装 `@l7/scene``@l7/layers`
```bash
npm install --save @l7/scene @l7/layers
// or
yarn add @l7/scene @l7/layers
```
然后就可以使用其中包含的场景和各类图层:
```typescript
import { Scene } from '@l7/scene';
import { PolygonLayer } from '@l7/layers';
(async function() {
// 获取数据
const response = await fetch(
'https://gw.alipayobjects.com/os/basement_prod/d2e0e930-fd44-4fca-8872-c1037b0fee7b.json',
);
const data = await response.json();
// 创建场景
const scene = new Scene({
center: [110.19382669582967, 50.258134],
id: 'map',
pitch: 0,
style: 'dark',
type: 'amap',
zoom: 3,
token: 'pg.xxx', // 高德或者 Mapbox 的 token
});
// 创建图层
const layer = new PolygonLayer({});
layer
.source(data)
.size('name', [0, 10000, 50000, 30000, 100000])
.color('name', [
'#2E8AE6',
'#69D1AB',
'#DAF291',
'#FFD591',
'#FF7A45',
'#CF1D49',
])
.shape('fill')
.style({
opacity: 0.8,
});
// 添加图层到场景中
scene.addLayer(layer);
// 渲染场景
scene.render();
})();
```
最后在 `<head>` 中引入 L7 CDN 版本的 CSS 文件:
```html
<head>
<link href='https://api.l7/v2.0.0-beta/l7.css' rel='stylesheet' />
</head>
```
L7 目前的文档都通过这种方式使用,可以参考项目中的 stories
* [高德地图](https://github.com/antvis/L7/blob/next/stories/MapAdaptor/components/AMap.tsx)
* [Mapbox](https://github.com/antvis/L7/blob/next/stories/MapAdaptor/components/Mapbox.tsx)
## [WIP] React
React 组件待开发,目前可以暂时以 Submodule 方式使用:
```tsx
import { Scene } from '@l7/scene';
import { PolygonLayer } from '@l7/layers';
import * as React from 'react';
export default class AMap extends React.Component {
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const response = await fetch(
'https://gw.alipayobjects.com/os/basement_prod/d2e0e930-fd44-4fca-8872-c1037b0fee7b.json',
);
const scene = new Scene({
center: [110.19382669582967, 50.258134],
id: 'map',
pitch: 0,
style: 'dark',
type: 'amap',
zoom: 3,
token: 'pg.xxx', // 高德或者 Mapbox 的 token
});
const layer = new PolygonLayer({});
layer
.source(await response.json())
.size('name', [0, 10000, 50000, 30000, 100000])
.color('name', [
'#2E8AE6',
'#69D1AB',
'#DAF291',
'#FFD591',
'#FF7A45',
'#CF1D49',
])
.shape('fill')
.style({
opacity: 0.8,
});
scene.addLayer(layer);
scene.render();
this.scene = scene;
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
/>
);
}
}
```
⚠️组件 Unmount 时需要通过 `scene.destroy()` 手动销毁场景。

174
docs/API/quickstart.zh.md Normal file
View File

@ -0,0 +1,174 @@
---
title: 快速上手
order: 0
redirect_from:
- /zh/docs/tutorial
---
# 使用方法
L7 提供三种使用方式CDN、Submodule 以及 React 组件。
## 通过 CDN 使用
首先在 `<head>` 中引入 L7 CDN 版本的 JS 和 CSS 文件:
```html
<head>
<script src='https://api.l7/v2.0.0-beta/l7.js'></script>
<link href='https://api.l7/v2.0.0-beta/l7.css' rel='stylesheet' />
</head>
```
如果使用 Mapbox还需要额外引入 Mapbox 的 JS 和 CSS 文件,这一步可以参考 [Mapbox 文档](https://docs.mapbox.com/mapbox-gl-js/overview/#quickstart)
```html
<head>
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v1.5.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v1.5.0/mapbox-gl.css' rel='stylesheet' />
<!-- 上一步引入的 L7 JS 和 CSS -->
</head>
```
⚠️高德采用异步加载,因此不需要引入任何额外静态文件。
然后在 `<body>` 中定义一个容器并设置一个 `id`。通过全局 `L7` 这个命名空间可以获取场景 `L7.Scene` 和图层 `L7.PolygonLayer`
⚠️需要获取高德或者 Mapbox 的使用 token 并传入 `L7.Scene` 的构造函数,获取方式如下:
* 高德地图开发者 Key [申请方法](https://lbs.amap.com/dev/key/)
* [Mapbox Access Tokens](https://docs.mapbox.com/help/how-mapbox-works/access-tokens/#creating-and-managing-access-tokens)
## 通过 Submodule 使用
首先通过 `npm/yarn` 安装 `@l7/scene``@l7/layers`
```bash
npm install --save @l7/scene @l7/layers
// or
yarn add @l7/scene @l7/layers
```
然后就可以使用其中包含的场景和各类图层:
```typescript
import { Scene } from '@l7/scene';
import { PolygonLayer } from '@l7/layers';
(async function() {
// 获取数据
const response = await fetch(
'https://gw.alipayobjects.com/os/basement_prod/d2e0e930-fd44-4fca-8872-c1037b0fee7b.json',
);
const data = await response.json();
// 创建场景
const scene = new Scene({
center: [110.19382669582967, 50.258134],
id: 'map',
pitch: 0,
style: 'dark',
type: 'amap',
zoom: 3,
token: 'pg.xxx', // 高德或者 Mapbox 的 token
});
// 创建图层
const layer = new PolygonLayer({});
layer
.source(data)
.size('name', [0, 10000, 50000, 30000, 100000])
.color('name', [
'#2E8AE6',
'#69D1AB',
'#DAF291',
'#FFD591',
'#FF7A45',
'#CF1D49',
])
.shape('fill')
.style({
opacity: 0.8,
});
// 添加图层到场景中
scene.addLayer(layer);
// 渲染场景
scene.render();
})();
```
最后在 `<head>` 中引入 L7 CDN 版本的 CSS 文件:
```html
<head>
<link href='https://api.l7/v2.0.0-beta/l7.css' rel='stylesheet' />
</head>
```
L7 目前的文档都通过这种方式使用,可以参考项目中的 stories
* [高德地图](https://github.com/antvis/L7/blob/next/stories/MapAdaptor/components/AMap.tsx)
* [Mapbox](https://github.com/antvis/L7/blob/next/stories/MapAdaptor/components/Mapbox.tsx)
## [WIP] React
React 组件待开发,目前可以暂时以 Submodule 方式使用:
```tsx
import { Scene } from '@l7/scene';
import { PolygonLayer } from '@l7/layers';
import * as React from 'react';
export default class AMap extends React.Component {
private scene: Scene;
public componentWillUnmount() {
this.scene.destroy();
}
public async componentDidMount() {
const response = await fetch(
'https://gw.alipayobjects.com/os/basement_prod/d2e0e930-fd44-4fca-8872-c1037b0fee7b.json',
);
const scene = new Scene({
center: [110.19382669582967, 50.258134],
id: 'map',
pitch: 0,
style: 'dark',
type: 'amap',
zoom: 3,
token: 'pg.xxx', // 高德或者 Mapbox 的 token
});
const layer = new PolygonLayer({});
layer
.source(await response.json())
.size('name', [0, 10000, 50000, 30000, 100000])
.color('name', [
'#2E8AE6',
'#69D1AB',
'#DAF291',
'#FFD591',
'#FF7A45',
'#CF1D49',
])
.shape('fill')
.style({
opacity: 0.8,
});
scene.addLayer(layer);
scene.render();
this.scene = scene;
}
public render() {
return (
<div
id="map"
style={{
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
}}
/>
);
}
}
```
⚠️组件 Unmount 时需要通过 `scene.destroy()` 手动销毁场景。

View File

@ -0,0 +1,27 @@
---
title: geojson
order: 1
---
# geojson 数据介绍
## 简介
GeoJSON是一种对各种地理数据结构进行编码的格式。GeoJSON对象可以表示几何、特征或者特征集合。GeoJSON支持下面几何类型点、线、面、多点、多线、多面和几何集合。GeoJSON里的特征包含一个几何对象和其他属性特征集合表示一系列特征。
[geojson详细文档]()
## Geojson相关的JS库
### 地理统计分析工具
[turfjs](http://turfjs.org/):  地理数据计算处理统计分析的Javascript 库
### 在线工具:
[http://geojson.io/](http://geojson.io/)    可以在线查看绘制修改GeoJSON数据
[https://mapshaper.org/](https://mapshaper.org/) 可以查看较大的geojson还能够简化GeoJSON数据

View File

@ -0,0 +1,27 @@
---
title: geojson
order: 1
---
# geojson 数据介绍
## 简介
GeoJSON是一种对各种地理数据结构进行编码的格式。GeoJSON对象可以表示几何、特征或者特征集合。GeoJSON支持下面几何类型点、线、面、多点、多线、多面和几何集合。GeoJSON里的特征包含一个几何对象和其他属性特征集合表示一系列特征。
[geojson详细文档]()
## Geojson相关的JS库
### 地理统计分析工具
[turfjs](http://turfjs.org/):  地理数据计算处理统计分析的Javascript 库
### 在线工具:
[http://geojson.io/](http://geojson.io/)    可以在线查看绘制修改GeoJSON数据
[https://mapshaper.org/](https://mapshaper.org/) 可以查看较大的geojson还能够简化GeoJSON数据

View File

@ -0,0 +1,298 @@
---
title: Source
order: 0
---
# Source
### 概述
source 地理数据处理模块主要包含数据解析parser),和数据处理(transform);
**parser:**
不同数据类型处理成统一数据格式。矢量数据包括 GeoJON, CSVJson等不同数据格式栅格数据包括RasterImage数据。将来还会支持瓦片格式数据。
**transform**
数据转换,数据统计,网格布局,数据聚合等数据操作。
## API
### parser
空间数据分矢量数据和栅格数据两大类
- 矢量数据 支持 csvgeojsonjson 三种数据类型
- 栅格数据 支持 imageRaster
#### geojson
[geojson](https://www.yuque.com/antv/l7/dm2zll) 数据为默认数据格式,可以
不需要设置parser 参数
```javascript
layer.source(data)
```
#### json
json 不是标准的地理数据结构,因此需要设置对应的经纬度字段
**点数据**
x: 经度字段
y: 纬度字段
```javascript
const data = [{
lng:112.345,
lat:30.455,
value: 10
},{
 lng:114.345,
lat:31.455,
value: 10
 }
]
layer.source(
data,
{
parser: {
type:'json',
x:'lng',
y:'lat',
}
})
```
**线段数据**
type: json
这里的直线表示有两个点组成的线段,主要绘制弧线的时候比较常用,只需指定线段的起始点坐标
x:经度字段 起点经度
y:纬度字段 起点纬度
x1:经度字段 终点经度
y1:纬度字段 终点纬度
```javascript
const data = [{
lng1:112.345,
lat1:30.455,
  lng2:112.345,
lat2:30.455,
value: 10
},{
 lng1:114.345,
lat1:31.455,
  lng2:112.345,
lat2:30.455,
value: 10
 }
];
layer.source(
data,
{
parser:{
type:'json',
x:'lng1',
y:'lat1' ,
    x1:'lng1',
y1:'lat2' ,
}
}
})
```
**面数据**
需要指定coordinates 字段, coordinates据格式
**注意面数据 coord  是三层数据结构**
```javascript
[ {
type: "Polygon",
'geometryCoord': [
[
[
115.1806640625,
30.637912028341123
],
[
114.9609375,
29.152161283318915
],
[
117.79541015625001,
27.430289738862594
],
[
118.740234375,
29.420460341013133
],
[
117.46582031249999,
31.50362930577303
],
[
115.1806640625,
30.637912028341123
]
]
]
}
]
layer.source(data,{
parser:{
type:'json',
coordinates:'geometryCoord'
}
})
```
#### csv
线数据配置项同json数据类型
```javascript
layer.source(
data,
{
parser:{
type:'csv',
x:'lng1',
y:'lat1' ,
    x1:'lng1',
y1:'lat2' ,
}
})
```
**栅格数据类型****
#### image
 根据图片的经纬度范围,将图片添加到地图上。 配置项
-  type: image
-  extent: 图像的经纬度范围 []
```javascript
layer.source('https://gw.alipayobjects.com/zos/rmsportal/FnHFeFklTzKDdUESRNDv.jpg',{
parser:{
type:'image',
extent: [ 121.1680, 30.2828, 121.3840, 30.4219 ]
}
})
```
 
#### raster
栅格数据类型主要表示遥感数据类型data 栅格数据的二维矩阵数据parser 配置项
- type  raster
- width  数据宽度二维矩阵 columns 
- height 数据高度
- min 数据最大值
- max 数据最小值
- extent 经纬度范围
```javascript
source(values, {
parser: {
type: 'raster',
width: n,
height: m,
min: 0,
max: 8000,
extent: [ 73.482190241, 3.82501784112, 135.106618732, 57.6300459963 ]
}
})
```
### transforms
目前支持三种数据处理方法 mapgridhexagon transform配置项
- type 数据处理类型
-  tansform cfg  数据处理配置项
#### map
数据处理支持自定义callback函数
- callback:function 回调函数
```javascript
layer.source(data, {
transforms:[
{
type: 'map',
callback:function(item){
const [x, y] = item.coordinates;
item.lat = item.lat*1;
item.lng = item.lng*1;
item.v = item.v *1;
item.coordinates = [x*1,y*1];
return item;
}
},
```
#### grid
生成方格网布局,根据数据字段统计,主要在网格热力图中使用
-  type: 'grid',
-  size: 网格半径
-  field: 数据统计字段
-  method:聚合方法  count,max,min,sum,mean5个统计维度
```javascript
layer.source(data, {
transforms:[
{
type: 'grid',
size: 15000,
field:'v',
method:'sum'
}
]
}
```
#### hexagon
生成六边形网格布局,根据数据字段统计
-  type: 'hexagon',
-  size: 网格半径
-  field: 数据统计字段
-  method:聚合方法  count,max,min,sum,mean5个统计维度
```

View File

@ -0,0 +1,298 @@
---
title: Source
order: 0
---
# Source
### 概述
source 地理数据处理模块主要包含数据解析parser),和数据处理(transform);
**parser:**
不同数据类型处理成统一数据格式。矢量数据包括 GeoJON, CSVJson等不同数据格式栅格数据包括RasterImage数据。将来还会支持瓦片格式数据。
**transform:**
数据转换,数据统计,网格布局,数据聚合等数据操作。
## API
### parser
空间数据分矢量数据和栅格数据两大类
- 矢量数据 支持 csvgeojsonjson 三种数据类型
- 栅格数据 支持 imageRaster
#### geojson
[geojson](https://www.yuque.com/antv/l7/dm2zll) 数据为默认数据格式,可以
不需要设置parser 参数
```javascript
layer.source(data);
```
#### json
json 不是标准的地理数据结构,因此需要设置对应的经纬度字段
**点数据**
x: 经度字段
y: 纬度字段
```javascript
const data = [{
lng:112.345,
lat:30.455,
value: 10
},{
 lng:114.345,
lat:31.455,
value: 10
 }
]
layer.source(
data,
{
parser: {
type:'json',
x:'lng',
y:'lat',
}
})
```
**线段数据**
type: json
这里的直线表示有两个点组成的线段,主要绘制弧线的时候比较常用,只需指定线段的起始点坐标
x:经度字段 起点经度
y:纬度字段 起点纬度
x1:经度字段 终点经度
y1:纬度字段 终点纬度
```javascript
const data = [{
lng1:112.345,
lat1:30.455,
  lng2:112.345,
lat2:30.455,
value: 10
},{
 lng1:114.345,
lat1:31.455,
  lng2:112.345,
lat2:30.455,
value: 10
 }
];
layer.source(
data,
{
parser:{
type:'json',
x:'lng1',
y:'lat1' ,
    x1:'lng1',
y1:'lat2' ,
}
}
})
```
**面数据**
需要指定coordinates 字段, coordinates据格式
**注意面数据 coord  是三层数据结构**
```javascript
[ {
type: "Polygon",
'geometryCoord': [
[
[
115.1806640625,
30.637912028341123
],
[
114.9609375,
29.152161283318915
],
[
117.79541015625001,
27.430289738862594
],
[
118.740234375,
29.420460341013133
],
[
117.46582031249999,
31.50362930577303
],
[
115.1806640625,
30.637912028341123
]
]
]
}
];
layer.source(data,{
parser:{
type:'json',
coordinates:'geometryCoord'
}
});
```
#### csv
线数据配置项同json数据类型
```javascript
layer.source(
data,
{
parser:{
type:'csv',
x:'lng1',
y:'lat1' ,
    x1:'lng1',
y1:'lat2' ,
}
})
```
**栅格数据类型****
#### image
 根据图片的经纬度范围,将图片添加到地图上。 配置项
-  type: image
-  extent: 图像的经纬度范围 []
```javascript
layer.source('https://gw.alipayobjects.com/zos/rmsportal/FnHFeFklTzKDdUESRNDv.jpg',{
parser:{
type:'image',
extent: [ 121.1680, 30.2828, 121.3840, 30.4219 ]
}
});
```
 
#### raster
栅格数据类型主要表示遥感数据类型data 栅格数据的二维矩阵数据parser 配置项
- type  raster
- width  数据宽度二维矩阵 columns 
- height 数据高度
- min 数据最大值
- max 数据最小值
- extent 经纬度范围
```javascript
source(values, {
parser: {
type: 'raster',
width: n,
height: m,
min: 0,
max: 8000,
extent: [ 73.482190241, 3.82501784112, 135.106618732, 57.6300459963 ]
}
});
```
### transforms
目前支持三种数据处理方法 mapgridhexagon transform配置项
- type 数据处理类型
-  tansform cfg  数据处理配置项
#### map
数据处理支持自定义callback函数
- callback:function 回调函数
```javascript
layer.source(data, {
transforms:[
{
type: 'map',
callback:function(item){
const [x, y] = item.coordinates;
item.lat = item.lat*1;
item.lng = item.lng*1;
item.v = item.v *1;
item.coordinates = [x*1,y*1];
return item;
}
}
]
});
```
#### grid
生成方格网布局,根据数据字段统计,主要在网格热力图中使用
-  type: 'grid',
-  size: 网格半径
-  field: 数据统计字段
-  method:聚合方法  count,max,min,sum,mean5个统计维度
```javascript
layer.source(data, {
transforms:[
{
type: 'grid',
size: 15000,
field:'v',
method:'sum'
}
],
})
```
#### hexagon
生成六边形网格布局,根据数据字段统计
-  type: 'hexagon',
-  size: 网格半径
-  field: 数据统计字段
-  method:聚合方法  count,max,min,sum,mean5个统计维度
```

View File

@ -63,3 +63,12 @@ GeoJSON 支持点、线、面,等所有的空间数据格式。<br />CSV 支
[http://geojson.io/](http://geojson.io/)    可以在线查看绘制修改GeoJSON数据 [http://geojson.io/](http://geojson.io/)    可以在线查看绘制修改GeoJSON数据
[https://mapshaper.org/](https://mapshaper.org/)  可以查看较大的geojson还能够简化GeoJSON数据 [https://mapshaper.org/](https://mapshaper.org/)  可以查看较大的geojson还能够简化GeoJSON数据
## 数据资源
#### 全国行政区划边界 
[支持 geojson, svg下载](http://datav.aliyun.com/tools/atlas/#&lat=33.50475906922609&lng=104.32617187499999&zoom=4)
#### HighCharts 全球行政区划数据集
[https://img.hcharts.cn/mapdata/](https://img.hcharts.cn/mapdata/)

View File

@ -1,6 +0,0 @@
---
title: quickStart
order: 0
redirect_from:
- /en/docs/tutorial
---

View File

@ -1,8 +0,0 @@
---
title: 快速上手
order: 0
redirect_from:
- /zh/docs/tutorial
---
内容

View File

@ -5,31 +5,29 @@ const scene = new Scene({
pitch: 0, pitch: 0,
type: 'mapbox', type: 'mapbox',
style: 'dark', style: 'dark',
center: [107.77791556935472, 35.443286920228644], center: [ 107.77791556935472, 35.443286920228644 ],
zoom: 2.9142882493605033, zoom: 2.9142882493605033
}); });
window.mapScene = scene; window.mapScene = scene;
fetch('https://gw.alipayobjects.com/os/rmsportal/UEXQMifxtkQlYfChpPwT.txt') fetch('https://gw.alipayobjects.com/os/rmsportal/UEXQMifxtkQlYfChpPwT.txt')
.then((res) => res.text()) .then(res => res.text())
.then((data) => { .then(data => {
const layer = const layer = new LineLayer({})
new LineLayer({}) .source(data, {
.source(data, { parser: {
parser: { type: 'csv',
type: 'csv', x: 'lng1',
x: 'lng1', y: 'lat1',
y: 'lat1', x1: 'lng2',
x1: 'lng2', y1: 'lat2'
y1: 'lat2', }
}, })
}) .size(1)
.size(1) .shape('arc')
.shape('arc') .color('#8C1EB2')
.color('#8C1EB2') .style({
.style({ opacity: 0.8,
opacity: 0.8, blur: 0.99
blur: 0.99 });
}) scene.addLayer(layer);
; });
scene.addLayer(layer);
})

View File

@ -1,42 +1,45 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { LineLayer } from '@l7/layers' import { LineLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
center: [103.83735604457024,1.360253881403068], center: [ 103.83735604457024, 1.360253881403068 ],
pitch: 4.00000000000001, pitch: 4.00000000000001,
zoom: 10.210275860702593, zoom: 10.210275860702593,
rotation: 19.313180925794313, rotation: 19.313180925794313,
type: 'mapbox', type: 'mapbox',
style: 'dark', style: 'dark'
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/ee07641d-5490-4768-9826-25862e8019e1.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/ee07641d-5490-4768-9826-25862e8019e1.json'
.then((data) => { )
const layer = .then(res => res.json())
new LineLayer({ .then(data => {
const layer = new LineLayer({})
.source(data, {
parser: {
coordinates: 'path',
type: 'json'
}
}) })
.source(data,{ .size('level', level => {
parser:{ return [ 1.0, level * 1 ];
type:'json', })
coordinates:'path' .shape('line')
} .color(
}) 'level',
.size('level',(level)=>{ [
return [1.0 , level * 1] '#312B60',
}) '#4A457E',
.shape('line') '#615C99',
.color( '#816CAD',
'level', '#A67FB5',
[ '#C997C7',
'#312B60', '#4A457E', '#DEB8D4',
'#615C99', '#816CAD', '#F5D4E6',
'#A67FB5', '#C997C7', '#FAE4F1',
'#DEB8D4', '#F5D4E6', '#FFF3FC'
'#FAE4F1', '#FFF3FC' ].slice(0, 8)
].slice(0,8) );
)
scene.addLayer(layer); scene.addLayer(layer);
console.log(layer);
}); });

View File

@ -1,44 +1,44 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer} from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 35.210526315789465, pitch: 35.210526315789465,
type: 'amap', type: 'amap',
style: 'dark', style: 'dark',
center: [108.524505, 29.873128], center: [ 104.288144, 31.239692 ],
zoom: 4.4, zoom: 4.4
}); });
window.mapScene = scene; window.mapScene = scene;
fetch('https://gw.alipayobjects.com/os/rmsportal/oVTMqfzuuRFKiDwhPSFL.json') fetch('https://gw.alipayobjects.com/os/rmsportal/oVTMqfzuuRFKiDwhPSFL.json')
.then((res) => res.json()) .then(res => res.json())
.then((data) => { .then(data => {
const pointLayer = const pointLayer = new PointLayer({})
new PointLayer({ .source(data.list, {
parser: {
type: 'json',
x: 'j',
y: 'w'
}
}) })
.source(data.list, { .shape('cylinder')
parser: { .size('t', function(level) {
type: 'json', return [ 1, 2, level * 2 + 20 ];
x: 'j', })
y: 'w' .color('t', [
} '#094D4A',
}) '#146968',
.shape('cylinder') '#1D7F7E',
.size('t', function(level) { '#289899',
return [1, 2, level * 2 + 20]; '#34B6B7',
}) '#4AC5AF',
.color('t',[ '#5FD3A6',
'#094D4A', '#146968', '#7BE39E',
'#1D7F7E', '#289899', '#A1EDB8',
'#34B6B7', '#4AC5AF', '#CEF8D6'
'#5FD3A6', '#7BE39E', ])
'#A1EDB8', '#CEF8D6' .style({
],) opacity: 1.0
.style({ });
opacity: 1.0, scene.addLayer(pointLayer);
}) });
scene.addLayer(pointLayer);
console.log(pointLayer);
});

View File

@ -4,56 +4,56 @@ const scene = new Scene({
id: 'map', id: 'map',
style: 'dark', style: 'dark',
pitch: 43, pitch: 43,
center: [120.13383079335335,29.651873105004427], center: [ 120.13383079335335, 29.651873105004427 ],
zoom: 7.068989519212174, zoom: 7.068989519212174,
type: 'mapbox', type: 'mapbox'
}); });
window.mapScene = scene; window.mapScene = scene;
fetch( fetch(
'https://gw.alipayobjects.com/os/basement_prod/a1a8158d-6fe3-424b-8e50-694ccf61c4d7.csv', 'https://gw.alipayobjects.com/os/basement_prod/a1a8158d-6fe3-424b-8e50-694ccf61c4d7.csv'
) )
.then((res) => res.text()) .then(res => res.text())
.then((data) => { .then(data => {
const layer = new HeatmapLayer({}) const layer = new HeatmapLayer({})
.source(data, { .source(data, {
parser: {
parser:{ type: 'csv',
type:'csv', x: 'lng',
x:'lng', y: 'lat'
y:'lat',
}, },
transforms: [ transforms: [
{ {
type: 'hexagon', type: 'hexagon',
size: 2500, size: 2500,
field: 'v', field: 'v',
method: 'sum', method: 'sum'
}, }
], ]
}) })
.size('sum', (sum)=>{ .size('sum', sum => {
return sum * 200; return sum * 200;
}) })
.shape('hexagonColumn') .shape('hexagonColumn')
.style({ .style({
coverage: 0.8, coverage: 0.8,
angle: 0, angle: 0,
opacity: 1.0, opacity: 1.0
}) })
.color( .color('sum', [
'sum', '#094D4A',
[ '#146968',
'#094D4A', '#146968', '#1D7F7E',
'#1D7F7E', '#289899', '#289899',
'#34B6B7', '#4AC5AF', '#34B6B7',
'#5FD3A6', '#7BE39E', '#4AC5AF',
'#A1EDB8', '#C3F9CC', '#5FD3A6',
'#DEFAC0', '#ECFFB1' '#7BE39E',
] '#A1EDB8',
); '#C3F9CC',
'#DEFAC0',
'#ECFFB1'
]);
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -1,34 +1,30 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
type: 'amap', type: 'amap',
style: 'dark', style: 'dark',
center: [121.417463, 31.215175], center: [ 121.417463, 31.215175 ],
pitch: 0, pitch: 0,
zoom: 11 zoom: 11
}); });
window.mapScene = scene; window.mapScene = scene;
fetch('https://gw.alipayobjects.com/os/rmsportal/BElVQFEFvpAKzddxFZxJ.txt') fetch('https://gw.alipayobjects.com/os/rmsportal/BElVQFEFvpAKzddxFZxJ.txt')
.then((res) => res.text()) .then(res => res.text())
.then((data) => { .then(data => {
const pointLayer = const pointLayer = new PointLayer({})
new PointLayer({
})
.source(data, { .source(data, {
parser: { parser: {
type: 'csv', type: 'csv',
y: 'lat', y: 'lat',
x: 'lng' x: 'lng'
} }
}).size(0.5) })
.size(0.5)
.color('#080298') .color('#080298')
.style({ .style({
opacity:1., opacity: 1
}) });
scene.addLayer(pointLayer); scene.addLayer(pointLayer);
});
})

View File

@ -1,36 +1,37 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 64.88, pitch: 64.88,
type: 'amap', type: 'amap',
style: 'dark', style: 'dark',
center: [114.060288, 22.53684], center: [ 114.060288, 22.53684 ],
zoom: 15.63, zoom: 15.63
}); });
window.mapScene = scene; window.mapScene = scene;
fetch('https://gw.alipayobjects.com/os/basement_prod/513add53-dcb2-4295-8860-9e7aa5236699.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/513add53-dcb2-4295-8860-9e7aa5236699.json'
.then((data) => { )
const pointLayer = .then(res => res.json())
new PointLayer({ .then(data => {
const pointLayer = new PointLayer({})
}) .source(data)
.source(data) .size(2)
.size(2) .color('h8', [
.color('h8',[ '#0A3663',
'#0A3663', '#1558AC', '#1558AC',
'#3771D9', '#4D89E5', '#3771D9',
'#64A5D3', '#72BED6', '#4D89E5',
'#83CED6', '#A6E1E0', '#64A5D3',
'#B8EFE2', '#D7F9F0' '#72BED6',
]) '#83CED6',
.style({ '#A6E1E0',
opacity:1., '#B8EFE2',
}) '#D7F9F0'
])
.style({
opacity: 1
});
scene.addLayer(pointLayer); scene.addLayer(pointLayer);
});
})

View File

@ -2,5 +2,5 @@
title: Gallery title: Gallery
order: 0 order: 0
redirect_from: redirect_from:
- /en/examples/ - /en/examples
--- ---

View File

@ -2,5 +2,5 @@
title: Gallery title: Gallery
order: 0 order: 0
redirect_from: redirect_from:
- /zh/examples/ - /zh/examples
--- ---

View File

@ -4,49 +4,59 @@ const scene = new Scene({
id: 'map', id: 'map',
style: 'light', style: 'light',
pitch: 0, pitch: 0,
center: [110.097892, 33.853662], center: [ 107.054293, 35.246265 ],
zoom: 4.056, zoom: 4.056,
type: 'amap', type: 'amap'
}); });
window.mapScene = scene; window.mapScene = scene;
fetch( fetch(
'https://gw.alipayobjects.com/os/basement_prod/7359a5e9-3c5e-453f-b207-bc892fb23b84.csv', 'https://gw.alipayobjects.com/os/basement_prod/7359a5e9-3c5e-453f-b207-bc892fb23b84.csv'
) )
.then((res) => res.text()) .then(res => res.text())
.then((data) => { .then(data => {
const layer = new HeatmapLayer({}) const layer = new HeatmapLayer({})
.source(data, { .source(data, {
parser: { parser: {
type: 'csv', type: 'csv',
x: 'lng', x: 'lng',
y: 'lat' y: 'lat'
}, },
transforms:[ transforms: [
{ {
type: 'grid', type: 'grid',
size: 20000, size: 20000,
field:'v', field: 'v',
method:'sum' method: 'sum'
} }
] ]
}) })
.size('count',(value)=>{ .size('count', value => {
return value * 0; return value * 0;
}) })
.shape('square') .shape('square')
.style({ .style({
coverage: 1, coverage: 1,
angle: 0, angle: 0
}) })
.color('count', [ .color(
'#0B0030', '#100243', 'count',
'#100243', '#1B048B', [
'#051FB7', '#0350C1', '#0B0030',
'#0350C1', '#0072C4', '#100243',
'#0796D3', '#2BA9DF', '#100243',
'#30C7C4', '#6BD5A0', '#1B048B',
'#A7ECB2', '#D0F4CA' '#051FB7',
].reverse()) '#0350C1',
'#0350C1',
'#0072C4',
'#0796D3',
'#2BA9DF',
'#30C7C4',
'#6BD5A0',
'#A7ECB2',
'#D0F4CA'
].reverse()
);
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -4,44 +4,50 @@ const scene = new Scene({
id: 'map', id: 'map',
style: 'dark', style: 'dark',
pitch: 0, pitch: 0,
center: [110.097892, 33.853662], center: [ 110.097892, 33.853662 ],
zoom: 4.056, zoom: 4.056,
type: 'amap', type: 'amap'
}); });
window.mapScene = scene; window.mapScene = scene;
fetch( fetch(
'https://gw.alipayobjects.com/os/basement_prod/7359a5e9-3c5e-453f-b207-bc892fb23b84.csv', 'https://gw.alipayobjects.com/os/basement_prod/7359a5e9-3c5e-453f-b207-bc892fb23b84.csv'
) )
.then((res) => res.text()) .then(res => res.text())
.then((data) => { .then(data => {
const layer = new HeatmapLayer({}) const layer = new HeatmapLayer({})
.source(data, { .source(data, {
parser: { parser: {
type: 'csv', type: 'csv',
x: 'lng', x: 'lng',
y: 'lat' y: 'lat'
}, },
transforms:[ transforms: [
{ {
type: 'grid', type: 'grid',
size: 10000, size: 10000,
field:'v', field: 'v',
method:'sum' method: 'sum'
} }
] ]
}) })
.size('count',(value)=>{ .size('count', value => {
return value * 0; return value * 0;
}) })
.shape('square') .shape('square')
.style({ .style({
coverage: 1, coverage: 1,
angle: 0, angle: 0
}) })
.color('count', [ .color(
'#FF4818', '#F7B74A', 'count',
'#FFF598', '#FF40F3', [
'#9415FF', '#421EB2' '#FF4818',
].reverse()) '#F7B74A',
'#FFF598',
'#FF40F3',
'#9415FF',
'#421EB2'
].reverse()
);
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -4,17 +4,16 @@ const scene = new Scene({
id: 'map', id: 'map',
style: 'light', style: 'light',
pitch: 0, pitch: 0,
pitch: 0, center: [ 110.097892, 33.853662 ],
center: [110.097892, 33.853662],
zoom: 4.056, zoom: 4.056,
type: 'amap', type: 'amap'
}); });
fetch( fetch(
'https://gw.alipayobjects.com/os/basement_prod/7359a5e9-3c5e-453f-b207-bc892fb23b84.csv', 'https://gw.alipayobjects.com/os/basement_prod/7359a5e9-3c5e-453f-b207-bc892fb23b84.csv'
) )
.then((res) => res.text()) .then(res => res.text())
.then((data) => { .then(data => {
const layer = new HeatmapLayer({}) const layer = new HeatmapLayer({})
.source(data, { .source(data, {
parser: { parser: {
@ -31,20 +30,30 @@ fetch(
} }
] ]
}) })
.size('count', (value) => { .size('count', value => {
return value * 0; return value * 0;
}) })
.shape('circle') .shape('circle')
.style({ .style({
coverage: 0.9, coverage: 0.9,
angle: 0, angle: 0
}) })
.color('count', [ .color(
'#8C1EB2', '#8C1EB2', '#DA05AA', 'count',
'#F0051A', '#FF2A3C', '#FF4818', [
'#FF4818', '#FF8B18', '#8C1EB2',
'#F77B00', '#ED9909', '#8C1EB2',
'#ECC357', '#EDE59C' '#DA05AA',
].reverse()) '#F0051A',
'#FF2A3C',
'#FF4818',
'#FF4818',
'#FF8B18',
'#F77B00',
'#ED9909',
'#ECC357',
'#EDE59C'
].reverse()
);
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -4,46 +4,53 @@ const scene = new Scene({
id: 'map', id: 'map',
style: 'dark', style: 'dark',
pitch: 0, pitch: 0,
center: [110.097892, 33.853662], center: [ 110.097892, 33.853662 ],
zoom: 4.056, zoom: 4.056,
type: 'amap', type: 'amap'
}); });
window.mapScene = scene; window.mapScene = scene;
fetch( fetch(
'https://gw.alipayobjects.com/os/basement_prod/7359a5e9-3c5e-453f-b207-bc892fb23b84.csv', 'https://gw.alipayobjects.com/os/basement_prod/7359a5e9-3c5e-453f-b207-bc892fb23b84.csv'
) )
.then((res) => res.text()) .then(res => res.text())
.then((data) => { .then(data => {
const layer = new HeatmapLayer({}) const layer = new HeatmapLayer({})
.source(data, { .source(data, {
parser: { parser: {
type: 'csv', type: 'csv',
x: 'lng', x: 'lng',
y: 'lat' y: 'lat'
}, },
transforms:[ transforms: [
{ {
type: 'grid', type: 'grid',
size: 10000, size: 10000,
field:'v', field: 'v',
method:'sum' method: 'sum'
} }
] ]
}) })
.size('count',(value)=>{ .size('count', value => {
return value * 0; return value * 0;
}) })
.shape('square') .shape('square')
.style({ .style({
coverage: 1, coverage: 1,
angle: 0, angle: 0
}) })
.color('count', [ .color(
'#FF3417', '#FF7412', 'count',
'#FFB02A', '#FFE754', [
'#46F3FF', '#02BEFF', '#FF3417',
'#1A7AFF', '#0A1FB2' '#FF7412',
].reverse()) '#FFB02A',
'#FFE754',
'#46F3FF',
'#02BEFF',
'#1A7AFF',
'#0A1FB2'
].reverse()
);
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -2,3 +2,4 @@
title: 网格热力图 title: 网格热力图
order: 1 order: 1
--- ---
热力图的变体,网格布局呈现数据分级分布的聚合现象。

View File

@ -4,30 +4,35 @@ const scene = new Scene({
id: 'map', id: 'map',
style: 'dark', style: 'dark',
pitch: 0, pitch: 0,
center: [127.5671666579043, 7.445038892195569], center: [ 127.5671666579043, 7.445038892195569 ],
type: 'mapbox', type: 'mapbox',
zoom: 2.632456779444394 zoom: 2.632456779444394
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json'
.then((data) => { )
const layer = .then(res => res.json())
new HeatmapLayer({ .then(data => {
}) const layer = new HeatmapLayer({})
.source(data) .source(data)
.shape('heatmap') .shape('heatmap')
.size('mag', [0, 1.0]) // weight映射通道 .size('mag', [ 0, 1.0 ]) // weight映射通道
.style({ .style({
intensity: 2, intensity: 2,
radius: 20, radius: 20,
opacity: 1.0, opacity: 1.0,
rampColors: { rampColors: {
colors: ['#FF4818', '#F7B74A', '#FFF598', '#91EABC', '#2EA9A1', '#206C7C'].reverse(), colors: [
positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0] '#FF4818',
} '#F7B74A',
}) '#FFF598',
'#91EABC',
'#2EA9A1',
'#206C7C'
].reverse(),
positions: [ 0, 0.2, 0.4, 0.6, 0.8, 1.0 ]
}
});
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -3,40 +3,39 @@ import { HeatmapLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
style: 'dark', style: 'dark',
pitch: 57.4999999, pitch: 58.5,
center: [116.49434030056, 39.868073421167621], center: [ 111.8759, 30.6942 ],
rotation: 0.519,
type: 'mapbox', type: 'mapbox',
zoom: 3, zoom: 3.6116
}); });
window.mapScene = scene; window.mapScene = scene;
fetch('https://gw.alipayobjects.com/os/basement_prod/337ddbb7-aa3f-4679-ab60-d64359241955.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/337ddbb7-aa3f-4679-ab60-d64359241955.json'
.then((data) => { )
const layer = .then(res => res.json())
new HeatmapLayer({ .then(data => {
}) const layer = new HeatmapLayer({})
.source(data) .source(data)
.size('capacity', [0, 1]) .size('capacity', [ 0, 1 ])
.shape('heatmap3D') .shape('heatmap3D')
// weight映射通道 // weight映射通道
.style({ .style({
intensity: 10, intensity: 10,
radius: 5, radius: 5,
opacity: 1.0, opacity: 1.0,
rampColors: { rampColors: {
colors:[ colors: [
'#2E8AE6', '#2E8AE6',
'#69D1AB', '#69D1AB',
'#DAF291', '#DAF291',
'#FFD591', '#FFD591',
'#FF7A45', '#FF7A45',
'#CF1D49', '#CF1D49'
], ],
positions: [0,0.2, 0.4, 0.6, 0.8, 1.0], positions: [ 0, 0.2, 0.4, 0.6, 0.8, 1.0 ]
}, }
}); });
scene.addLayer(layer); scene.addLayer(layer);
console.log(layer)
}); });

View File

@ -4,30 +4,35 @@ const scene = new Scene({
id: 'map', id: 'map',
style: 'dark', style: 'dark',
pitch: 0, pitch: 0,
center: [127.5671666579043,7.445038892195569], center: [ 127.5671666579043, 7.445038892195569 ],
type: 'mapbox', type: 'mapbox',
zoom: 2.632456779444394 zoom: 2.632456779444394
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json'
.then((data) => { )
const layer = .then(res => res.json())
new HeatmapLayer({ .then(data => {
}) const layer = new HeatmapLayer({})
.source(data) .source(data)
.shape('heatmap') .shape('heatmap')
.size('mag', [0, 1.0]) // weight映射通道 .size('mag', [ 0, 1.0 ]) // weight映射通道
.style({ .style({
intensity: 2, intensity: 2,
radius: 20, radius: 20,
opacity: 1.0, opacity: 1.0,
rampColors: { rampColors: {
colors: [ '#FF4818', '#F7B74A', '#FFF598', '#F27DEB', '#8C1EB2', '#421EB2' ].reverse(), colors: [
positions: [0, 0.2, 0.4, 0.6, 0.8, 1.0] '#FF4818',
} '#F7B74A',
}) '#FFF598',
'#F27DEB',
'#8C1EB2',
'#421EB2'
].reverse(),
positions: [ 0, 0.2, 0.4, 0.6, 0.8, 1.0 ]
}
});
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -1,4 +1,7 @@
--- ---
title: 经典热力图 title: 经典热力图
order: 0 order: 0
redirect_from:
- /zh/examples/heatmap/
--- ---
区域范围内数据具有的一定热度分级分布情况的聚合面状现象,常用于描述人群分布、密度和变化趋势等。

View File

@ -4,45 +4,51 @@ const scene = new Scene({
id: 'map', id: 'map',
style: 'dark', style: 'dark',
pitch: 47.49999999999995, pitch: 47.49999999999995,
center: [112.50447776627743,30.830476390931125], center: [ 112.50447776627743, 30.830476390931125 ],
zoom: 3.9879693680088626, zoom: 3.9879693680088626,
type: 'mapbox', type: 'mapbox'
}); });
window.mapScene = scene; window.mapScene = scene;
fetch( fetch(
'https://gw.alipayobjects.com/os/basement_prod/7359a5e9-3c5e-453f-b207-bc892fb23b84.csv', 'https://gw.alipayobjects.com/os/basement_prod/7359a5e9-3c5e-453f-b207-bc892fb23b84.csv'
) )
.then((res) => res.text()) .then(res => res.text())
.then((data) => { .then(data => {
const layer = new HeatmapLayer({}) const layer = new HeatmapLayer({})
.source(data, { .source(data, {
parser: { parser: {
type: 'csv', type: 'csv',
x: 'lng', x: 'lng',
y: 'lat' y: 'lat'
}, },
transforms:[ transforms: [
{ {
type: 'hexagon', type: 'hexagon',
size: 17000, size: 17000,
field:'v', field: 'v',
method:'sum' method: 'sum'
} }
] ]
}) })
.size('sum',(value)=>{ .size('sum', value => {
return value * 20; return value * 20;
}) })
.shape('hexagonColumn') .shape('hexagonColumn')
.color('count',[ .color(
'#FF4818', '#F7B74A', 'count',
'#FFF598', '#FF40F3', [
'#9415FF', '#421EB2' '#FF4818',
].reverse()) '#F7B74A',
.style({ '#FFF598',
coverage: 0.9, '#FF40F3',
angle: 0, '#9415FF',
}) '#421EB2'
].reverse()
)
.style({
coverage: 0.9,
angle: 0
});
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -3,17 +3,18 @@ import { Scene } from '@l7/scene';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
style: 'light', style: 'light',
pitch: 47.49999999999995, pitch: 56.499,
center: [114.05737552216226, 22.542656745583486], center: [ 114.07737552216226, 22.542656745583486 ],
zoom: 12.405122702055305, rotation: 39.19,
type: 'mapbox', zoom: 12.47985,
type: 'mapbox'
}); });
window.mapScene = scene; window.mapScene = scene;
fetch( fetch(
'https://gw.alipayobjects.com/os/basement_prod/513add53-dcb2-4295-8860-9e7aa5236699.json', 'https://gw.alipayobjects.com/os/basement_prod/513add53-dcb2-4295-8860-9e7aa5236699.json'
) )
.then((res) => res.json()) .then(res => res.json())
.then((data) => { .then(data => {
const layer = new HeatmapLayer({}) const layer = new HeatmapLayer({})
.source(data, { .source(data, {
transforms: [ transforms: [
@ -21,26 +22,31 @@ fetch(
type: 'hexagon', type: 'hexagon',
size: 100, size: 100,
field: 'h12', field: 'h12',
method: 'sum', method: 'sum'
}, }
], ]
}) })
.size('sum', [0, 600]) .size('sum', [ 0, 600 ])
.shape('hexagonColumn') .shape('hexagonColumn')
.style({ .style({
coverage: 0.8, coverage: 0.8,
angle: 0, angle: 0,
opacity: 1.0, opacity: 1.0
}) })
.color( .color(
'sum', 'sum',
[ [
'#094D4A', '#146968', '#094D4A',
'#1D7F7E', '#289899', '#146968',
'#34B6B7', '#4AC5AF', '#1D7F7E',
'#5FD3A6', '#7BE39E', '#289899',
'#A1EDB8', '#CEF8D6' '#34B6B7',
].reverse() '#4AC5AF',
'#5FD3A6',
'#7BE39E',
'#A1EDB8',
'#CEF8D6'
].reverse()
); );
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -1,59 +1,59 @@
import { HeatMapHexagonLayer, HeatMapGrid3dLayer } from '@l7/layers'; import { HeatmapLayer } from '@l7/layers';
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
style: 'dark', style: 'dark',
pitch: 43, pitch: 43,
center: [120.13383079335335,29.651873105004427], center: [ 120.13383079335335, 29.651873105004427 ],
zoom: 7.068989519212174, zoom: 7.068989519212174,
type: 'mapbox', type: 'mapbox'
}); });
window.mapScene = scene; window.mapScene = scene;
fetch( fetch(
'https://gw.alipayobjects.com/os/basement_prod/a1a8158d-6fe3-424b-8e50-694ccf61c4d7.csv', 'https://gw.alipayobjects.com/os/basement_prod/a1a8158d-6fe3-424b-8e50-694ccf61c4d7.csv'
) )
.then((res) => res.text()) .then(res => res.text())
.then((data) => { .then(data => {
const layer = new HeatMapGrid3dLayer({}) const layer = new HeatmapLayer({})
.source(data, { .source(data, {
parser: {
parser:{ type: 'csv',
type:'csv', x: 'lng',
x:'lng', y: 'lat'
y:'lat',
}, },
transforms: [ transforms: [
{ {
type: 'hexagon', type: 'hexagon',
size: 2500, size: 2500,
field: 'v', field: 'v',
method: 'sum', method: 'sum'
}, }
], ]
}) })
.size('sum', (sum)=>{ .size('sum', sum => {
return sum * 200; return sum * 200;
}) })
.shape('hexagonColumn') .shape('hexagonColumn')
.style({ .style({
coverage: 0.8, coverage: 0.8,
angle: 0, angle: 0,
opacity: 1.0, opacity: 1.0
}) })
.color( .color('sum', [
'sum', '#094D4A',
[ '#146968',
'#094D4A', '#146968', '#1D7F7E',
'#1D7F7E', '#289899', '#289899',
'#34B6B7', '#4AC5AF', '#34B6B7',
'#5FD3A6', '#7BE39E', '#4AC5AF',
'#A1EDB8', '#C3F9CC', '#5FD3A6',
'#DEFAC0', '#ECFFB1' '#7BE39E',
] '#A1EDB8',
); '#C3F9CC',
'#DEFAC0',
'#ECFFB1'
]);
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -21,7 +21,7 @@
{ {
"filename": "world.js", "filename": "world.js",
"title": "蜂窝热力图", "title": "蜂窝热力图",
"screenshot":"https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*tq4hR7QfQ0AAAAAAAAAAAABkARQnAQ" "screenshot":"https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*C3V7ToIoEvkAAAAAAAAAAABkARQnAQ"
} }
] ]
} }

View File

@ -4,46 +4,52 @@ const scene = new Scene({
id: 'map', id: 'map',
style: 'light', style: 'light',
pitch: 0, pitch: 0,
center: [116.49434030056, 39.868073421167621], center: [ 104.995156, 31.450658 ],
type: 'amap', type: 'amap',
zoom: 3, zoom: 3.79
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/337ddbb7-aa3f-4679-ab60-d64359241955.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/337ddbb7-aa3f-4679-ab60-d64359241955.json'
.then((data) => { )
const layer = .then(res => res.json())
new HeatmapLayer({ .then(data => {
}) const layer = new HeatmapLayer({})
.source(data, { .source(data, {
transforms: [ transforms: [
{ {
type: 'hexagon', type: 'hexagon',
size: 90000, size: 90000,
field: 'capacity', field: 'capacity',
method: 'sum', method: 'sum'
}, }
], ]
}) })
.size('sum', (value) => { .size('sum', value => {
return value * 50; return value * 50;
}) })
.shape('hexagon') .shape('hexagon')
.style({ .style({
coverage: 0.9, coverage: 0.9,
angle: 0, angle: 0,
opacity: 1.0, opacity: 1.0
}) })
.color('sum', [ .color(
'#1D2BB2', '#06117C', 'sum',
'#06117C', '#06117C', [
'#1D2BB2', '#1D2BB2', '#3F4BBA',
'#1D2BB2', '#0F62FF', '#3F4BBA',
'#0F62FF', '#0CB7FF', '#3F4BBA',
'#0CB7FF', '#52F1FC' '#3F4BBA',
'#3C73DA',
].reverse()); '#3C73DA',
'#3C73DA',
'#0F62FF',
'#0F62FF',
'#30B2E9',
'#30B2E9',
'#40C4CE'
].reverse()
);
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -2,3 +2,4 @@
title: 蜂窝热力图 title: 蜂窝热力图
order: 1 order: 1
--- ---
热力图的变体,蜂窝布局呈现数据分级分布的聚合现象。

View File

@ -5,40 +5,34 @@ const scene = new Scene({
pitch: 0, pitch: 0,
type: 'mapbox', type: 'mapbox',
style: 'dark', style: 'dark',
center: [0., 23.107329], center: [ 0, 23.107329 ],
zoom: 0, zoom: 0
}); });
console.time('loadData'); fetch(
fetch('https://gw.alipayobjects.com/os/basement_prod/b83699f9-a96d-49b8-b2ea-f99299faebaf.json') 'https://gw.alipayobjects.com/os/basement_prod/b83699f9-a96d-49b8-b2ea-f99299faebaf.json'
.then((res) => res.json()) )
.then((data) => { .then(res => res.json())
console.timeEnd('loadData'); .then(data => {
function getAirportCoord(idx) { function getAirportCoord(idx) {
return [data.airports[idx][3], data.airports[idx][4]]; return [ data.airports[idx][3], data.airports[idx][4] ];
} }
const routes = data.routes.map(function (airline) { const routes = data.routes.map(function(airline) {
return { return {
coord: [ coord: [ getAirportCoord(airline[1]), getAirportCoord(airline[2]) ]
getAirportCoord(airline[1]), };
getAirportCoord(airline[2])
]
}
}); });
console.timeEnd('loadData'); const layer = new LineLayer({})
const layer = .source(routes, {
new LineLayer({}) parser: {
.source(routes, { type: 'json',
parser: { coordinates: 'coord'
type: 'json', }
coordinates: 'coord', })
}, .size(0.6)
}) .shape('arc')
.size(0.6) .color('rgb(5, 5, 50)')
.shape('arc') .style({
.color('rgb(5, 5, 50)') opacity: 0.05
.style({ });
opacity: 0.05,
})
;
scene.addLayer(layer); scene.addLayer(layer);
}) });

View File

@ -5,30 +5,28 @@ const scene = new Scene({
pitch: 0, pitch: 0,
type: 'mapbox', type: 'mapbox',
style: 'dark', style: 'dark',
center: [107.77791556935472, 35.443286920228644], center: [ 107.77791556935472, 35.443286920228644 ],
zoom: 2.9142882493605033, zoom: 2.9142882493605033
}); });
fetch('https://gw.alipayobjects.com/os/rmsportal/UEXQMifxtkQlYfChpPwT.txt') fetch('https://gw.alipayobjects.com/os/rmsportal/UEXQMifxtkQlYfChpPwT.txt')
.then((res) => res.text()) .then(res => res.text())
.then((data) => { .then(data => {
const layer = const layer = new LineLayer({})
new LineLayer({}) .source(data, {
.source(data, { parser: {
parser: { type: 'csv',
type: 'csv', x: 'lng1',
x: 'lng1', y: 'lat1',
y: 'lat1', x1: 'lng2',
x1: 'lng2', y1: 'lat2'
y1: 'lat2', }
}, })
}) .size(1)
.size(1) .shape('greatcircle')
.shape('greatcircle') .color('#8C1EB2')
.color('#8C1EB2') .style({
.style({ opacity: 0.8,
opacity: 0.8, blur: 0.99
blur: 0.99 });
})
;
scene.addLayer(layer); scene.addLayer(layer);
}) });

View File

@ -5,30 +5,30 @@ const scene = new Scene({
pitch: 60, pitch: 60,
type: 'mapbox', type: 'mapbox',
style: 'light', style: 'light',
center: [-74.06355155037261,40.73507179789368], center: [ -74.06967, 40.720399 ],
zoom: 11.8623, zoom: 12.45977
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/bd33a685-a17e-4686-bc79-b0e6a89fd950.csv') fetch(
.then((res) => res.text()) 'https://gw.alipayobjects.com/os/basement_prod/bd33a685-a17e-4686-bc79-b0e6a89fd950.csv'
.then((data) => { )
const layer = .then(res => res.text())
new LineLayer({}) .then(data => {
.source(data, { const layer = new LineLayer({})
parser: { .source(data, {
type: 'csv', parser: {
x: 'start station longitude', type: 'csv',
y: 'start station latitude', x: 'start station longitude',
x1: 'end station longitude', y: 'start station latitude',
y1: 'end station latitude', x1: 'end station longitude',
}, y1: 'end station latitude'
}) }
.size(1) })
.shape('arc3d') .size(1)
.color('#0C47BF') .shape('arc3d')
.style({ .color('#0C47BF')
opacity: 1, .style({
blur: 0.9 opacity: 1,
}) blur: 0.9
; });
scene.addLayer(layer); scene.addLayer(layer);
}) });

View File

@ -5,31 +5,29 @@ const scene = new Scene({
pitch: 60, pitch: 60,
type: 'mapbox', type: 'mapbox',
style: 'dark', style: 'dark',
center: [104.92827320100344,41.209090496438364], center: [ 104.34278, 41.12554 ],
zoom: 2.8844827033002813, zoom: 2.94888,
rotation: 80, rotation: 42.3999
}); });
fetch('https://gw.alipayobjects.com/os/rmsportal/UEXQMifxtkQlYfChpPwT.txt') fetch('https://gw.alipayobjects.com/os/rmsportal/UEXQMifxtkQlYfChpPwT.txt')
.then((res) => res.text()) .then(res => res.text())
.then((data) => { .then(data => {
const layer = const layer = new LineLayer({})
new LineLayer({}) .source(data, {
.source(data, { parser: {
parser: { type: 'csv',
type: 'csv', x: 'lng1',
x: 'lng1', y: 'lat1',
y: 'lat1', x1: 'lng2',
x1: 'lng2', y1: 'lat2'
y1: 'lat2', }
}, })
}) .size(1)
.size(1) .shape('arc3d')
.shape('arc3d') .color('#FF7C6A')
.color('#FF7C6A') .style({
.style({ opacity: 0.8
opacity: 0.8, });
})
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -2,3 +2,4 @@
title: 弧线地图 title: 弧线地图
order: 1 order: 1
--- ---
将两个点的连线绘制成弧形,绘制的弧线可以是贝塞尔曲线,大圆航线,通常用来表示两种地理事物关系和联系,或者人口迁移,物流起点目的地等。

View File

@ -1,42 +1,40 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { LineLayer } from '@l7/layers' import { LineLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 40.89473684210526, pitch: 53.6305,
type: 'amap', type: 'amap',
style: 'light', style: 'light',
center: [102.60244, 23.10556], center: [ 102.600579, 23.114887 ],
zoom: 14.28, zoom: 14.66
}); });
fetch('https://gw.alipayobjects.com/os/rmsportal/ZVfOvhVCzwBkISNsuKCc.json') fetch('https://gw.alipayobjects.com/os/rmsportal/ZVfOvhVCzwBkISNsuKCc.json')
.then((res) => res.json()) .then(res => res.json())
.then((data) => { .then(data => {
const layer = const layer = new LineLayer({})
new LineLayer({ .source(data)
.size('ELEV', h => {
return [ h % 50 === 0 ? 1.0 : 0.5, (h - 1300) * 20 ];
}) })
.source(data) .shape('line')
.size('ELEV', (h) => { .scale('ELEV', {
return [h % 50 === 0 ? 1.0 : 0.5, (h -1300) *20 ]; type: 'quantize'
}) })
.shape('line') .color(
.scale('ELEV', { 'ELEV',
type: 'quantize' [
}) '#E4682F',
.color( '#FF8752',
'ELEV', '#FFA783',
[ '#E4682F', '#FFBEA8',
'#FF8752', '#FFDCD6',
'#FFA783', '#EEF3FF',
'#FFBEA8', '#C8D7F5',
'#FFDCD6', '#A5C1FC',
'#EEF3FF', '#7FA7F9',
'#C8D7F5', '#5F8AE5'
'#A5C1FC', ].reverse()
'#7FA7F9', );
'#5F8AE5' ].reverse()
)
scene.addLayer(layer); scene.addLayer(layer);
console.log(layer);
}); });

View File

@ -1,38 +1,37 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { LineLayer } from '@l7/layers' import { LineLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 26.842105263157915, pitch: 26.842105263157915,
type: 'amap', type: 'amap',
style: 'dark', style: 'dark',
center: [102.601919, 23.108997], center: [ 102.599436, 23.116371 ],
zoom: 14.22, zoom: 14.78
}); });
fetch('https://gw.alipayobjects.com/os/rmsportal/ZVfOvhVCzwBkISNsuKCc.json') fetch('https://gw.alipayobjects.com/os/rmsportal/ZVfOvhVCzwBkISNsuKCc.json')
.then((res) => res.json()) .then(res => res.json())
.then((data) => { .then(data => {
const layer = const layer = new LineLayer({})
new LineLayer({ .source(data)
.size('ELEV', h => {
return [ h % 50 === 0 ? 1.0 : 0.5, (h - 1300) * 20 ];
}) })
.source(data) .shape('line')
.size('ELEV', (h) => { .scale('ELEV', {
return [h % 50 === 0 ? 1.0 : 0.5, (h -1300) *20 ]; type: 'quantize'
}) })
.shape('line') .color('ELEV', [
.scale('ELEV', { '#094D4A',
type: 'quantize' '#146968',
}) '#1D7F7E',
.color( '#289899',
'ELEV',[ '#34B6B7',
'#094D4A', '#146968', '#4AC5AF',
'#1D7F7E', '#289899', '#5FD3A6',
'#34B6B7', '#4AC5AF', '#7BE39E',
'#5FD3A6', '#7BE39E', '#A1EDB8',
'#A1EDB8', '#CEF8D6' '#CEF8D6'
], ]);
)
scene.addLayer(layer); scene.addLayer(layer);
console.log(layer); });
});

View File

@ -1,33 +1,40 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { LineLayer } from '@l7/layers' import { LineLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 0, pitch: 0,
type: 'amap', type: 'amap',
style: 'light', style: 'light',
center: [104.117492,36.492696], center: [ 104.117492, 36.492696 ],
zoom: 3.89, zoom: 3.89
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/9f6afbcd-3aec-4a26-bd4a-2276d3439e0d.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/9f6afbcd-3aec-4a26-bd4a-2276d3439e0d.json'
.then((data) => { )
const layer = .then(res => res.json())
new LineLayer({ .then(data => {
const layer = new LineLayer({})
.source(data)
.scale('value', {
type: 'quantile'
}) })
.source(data) .size('value', [ 0.5, 1, 1.5, 2 ])
.scale('value',{ .shape('line')
type: 'quantile' .color(
}) 'value',
.size('value', [0.5, 1, 1.5, 2]) [
.shape('line') '#0A3663',
.color('value', [ '#1558AC',
'#0A3663', '#1558AC', '#3771D9',
'#3771D9', '#4D89E5', '#4D89E5',
'#64A5D3', '#72BED6', '#64A5D3',
'#83CED6', '#A6E1E0', '#72BED6',
'#B8EFE2', '#D7F9F0' '#83CED6',
].reverse()) '#A6E1E0',
'#B8EFE2',
'#D7F9F0'
].reverse()
);
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -2,3 +2,4 @@
title: 等值线地图 title: 等值线地图
order: 2 order: 2
--- ---
指需要用一连串首尾闭合相等数值点的连线的图层,表示连续分布且逐渐变化的数量特征的地图,常用于等高线图、等温线图等图。

View File

@ -1,33 +1,40 @@
import { Scene } from './node_modules/@l7/scene'; import { Scene } from './node_modules/@l7/scene';
import { LineLayer } from './node_modules/@l7/layers' import { LineLayer } from './node_modules/@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 0, pitch: 0,
type: 'amap', type: 'amap',
style: 'light', style: 'light',
center: [104.117492,36.492696], center: [ 104.117492, 36.492696 ],
zoom: 3.89, zoom: 3.89
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/9f6afbcd-3aec-4a26-bd4a-2276d3439e0d.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/9f6afbcd-3aec-4a26-bd4a-2276d3439e0d.json'
.then((data) => { )
const layer = .then(res => res.json())
new LineLayer({ .then(data => {
const layer = new LineLayer({})
.source(data)
.scale('value', {
type: 'quantile'
}) })
.source(data) .size('value', [ 0.5, 1, 1.5, 2 ])
.scale('value',{ .shape('line')
type: 'quantile' .color(
}) 'value',
.size('value', [0.5, 1, 1.5, 2]) [
.shape('line') '#0A3663',
.color('value', [ '#1558AC',
'#0A3663', '#1558AC', '#3771D9',
'#3771D9', '#4D89E5', '#4D89E5',
'#64A5D3', '#72BED6', '#64A5D3',
'#83CED6', '#A6E1E0', '#72BED6',
'#B8EFE2', '#D7F9F0' '#83CED6',
].reverse()) '#A6E1E0',
'#B8EFE2',
'#D7F9F0'
].reverse()
);
scene.addLayer(layer); scene.addLayer(layer);
}); });

View File

@ -1,42 +1,45 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { LineLayer } from '@l7/layers' import { LineLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
center: [103.83735604457024,1.360253881403068], center: [ 103.83735604457024, 1.360253881403068 ],
pitch: 4.00000000000001, pitch: 4.00000000000001,
zoom: 10.210275860702593, zoom: 10.210275860702593,
rotation: 19.313180925794313, rotation: 19.313180925794313,
type: 'mapbox', type: 'mapbox',
style: 'dark', style: 'dark'
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/ee07641d-5490-4768-9826-25862e8019e1.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/ee07641d-5490-4768-9826-25862e8019e1.json'
.then((data) => { )
const layer = .then(res => res.json())
new LineLayer({ .then(data => {
const layer = new LineLayer({})
.source(data, {
parser: {
type: 'json',
coordinates: 'path'
}
}) })
.source(data,{ .size('level', level => {
parser:{ return [ 0.8, level * 1 ];
type:'json', })
coordinates:'path' .shape('line')
} .color(
}) 'level',
.size('level',(level)=>{ [
return [0.8 , level * 1] '#312B60',
}) '#4A457E',
.shape('line') '#615C99',
.color( '#816CAD',
'level', '#A67FB5',
[ '#C997C7',
'#312B60', '#4A457E', '#DEB8D4',
'#615C99', '#816CAD', '#F5D4E6',
'#A67FB5', '#C997C7', '#FAE4F1',
'#DEB8D4', '#F5D4E6', '#FFF3FC'
'#FAE4F1', '#FFF3FC' ].slice(0, 8)
].slice(0,8) );
)
scene.addLayer(layer); scene.addLayer(layer);
console.log(layer);
}); });

View File

@ -1,42 +1,47 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { LineLayer } from '@l7/layers' import { LineLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
center: [103.83735604457024,1.360253881403068], center: [ 103.83735604457024, 1.360253881403068 ],
pitch: 4.00000000000001, pitch: 4.00000000000001,
zoom: 10.210275860702593, zoom: 10.210275860702593,
rotation: 19.313180925794313, rotation: 19.313180925794313,
type: 'mapbox', type: 'mapbox',
style: 'light', style: 'light'
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/ee07641d-5490-4768-9826-25862e8019e1.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/ee07641d-5490-4768-9826-25862e8019e1.json'
.then((data) => { )
const layer = .then(res => res.json())
new LineLayer({ .then(data => {
const layer = new LineLayer({})
.source(data, {
parser: {
type: 'json',
coordinates: 'path'
}
}) })
.source(data,{ .size('level', level => {
parser:{ return [ 0.8, level * 1 ];
type:'json', })
coordinates:'path' .shape('line')
} .color(
}) 'level',
.size('level',(level)=>{ [
return [0.8 , level * 1] '#0A3663',
}) '#1558AC',
.shape('line') '#3771D9',
.color( '#4D89E5',
'level', '#64A5D3',
[ '#72BED6',
'#0A3663', '#1558AC', '#83CED6',
'#3771D9', '#4D89E5', '#A6E1E0',
'#64A5D3', '#72BED6', '#B8EFE2',
'#83CED6', '#A6E1E0', '#D7F9F0'
'#B8EFE2', '#D7F9F0' ]
].slice(0,8) .reverse()
) .slice(0, 8)
);
scene.addLayer(layer); scene.addLayer(layer);
console.log(layer);
}); });

View File

@ -1,29 +1,24 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { LineLayer } from '@l7/layers' import { LineLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
center: [116.3956,39.9392], center: [ 116.3956, 39.9392 ],
pitch: 0, pitch: 0,
zoom: 10, zoom: 10,
rotation: 0, rotation: 0,
type: 'mapbox', type: 'mapbox',
style: 'dark', style: 'dark'
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/0d2f0113-f48b-4db9-8adc-a3937243d5a3.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/0d2f0113-f48b-4db9-8adc-a3937243d5a3.json'
.then((data) => { )
const layer = .then(res => res.json())
new LineLayer({ .then(data => {
}) const layer = new LineLayer({})
.source(data) .source(data)
.size(1.5) .size(1.5)
.shape('line') .shape('line')
.color( .color('标准名称', [ '#5B8FF9', '#5CCEA1', '#F6BD16' ]);
'标准名称',
['#5B8FF9','#5CCEA1','#F6BD16' ]
)
scene.addLayer(layer); scene.addLayer(layer);
console.log(layer);
}); });

View File

@ -1,29 +1,24 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { LineLayer } from '@l7/layers' import { LineLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
center: [116.3956,39.9392], center: [ 116.3956, 39.9392 ],
pitch: 0, pitch: 0,
zoom: 10, zoom: 10,
rotation: 0, rotation: 0,
type: 'mapbox', type: 'mapbox',
style: 'light', style: 'light'
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/0d2f0113-f48b-4db9-8adc-a3937243d5a3.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/0d2f0113-f48b-4db9-8adc-a3937243d5a3.json'
.then((data) => { )
const layer = .then(res => res.json())
new LineLayer({ .then(data => {
}) const layer = new LineLayer({})
.source(data) .source(data)
.size(1.5) .size(1.5)
.shape('line') .shape('line')
.color( .color('标准名称', [ '#5B8FF9', '#5CCEA1', '#5D7092' ]);
'标准名称',
['#5B8FF9','#5CCEA1','#5D7092' ]
)
scene.addLayer(layer); scene.addLayer(layer);
console.log(layer); });
});

View File

@ -2,3 +2,4 @@
title: 路径地图 title: 路径地图
order: 0 order: 0
--- ---
指需要用一连串首尾不闭合的点坐标对来定位的线图层,通常用来表示轨迹,线路,道路等

View File

@ -1,48 +1,44 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 0, pitch: 0,
type: 'amap', type: 'amap',
style: 'light', style: 'light',
center: [121.40, 31.258134], center: [ 121.435159, 31.256971 ],
zoom: 15, zoom: 14.89,
minZoom: 10 minZoom: 10
}); });
scene.mapScene = scene; fetch(
fetch('https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json') 'https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json'
.then((res) => res.json()) )
.then((data) => { .then(res => res.json())
const pointLayer = .then(data => {
new PointLayer({ const pointLayer = new PointLayer({})
.source(data, {
parser: {
type: 'json',
x: 'longitude',
y: 'latitude'
}
}) })
.source(data, { .shape('name', [
parser: { 'circle',
type: 'json', 'triangle',
x: 'longitude', 'square',
y: 'latitude' 'pentagon',
} 'hexagon',
}).shape('name',[ 'octogon',
'circle', 'hexagram',
'triangle', 'rhombus',
'square', 'vesica'
'pentagon', ])
'hexagon', .size('unit_price', [ 10, 25 ])
'octogon', .color('name', [ '#5B8FF9', '#5CCEA1', '#5D7092', '#F6BD16', '#E86452' ])
'hexagram', .style({
'rhombus', opacity: 0.3,
'vesica', strokeWidth: 2
]) });
.size('unit_price', [10, 25])
.color('name',['#5B8FF9',"#5CCEA1", "#5D7092","#F6BD16","#E86452"])
.style({
opacity:0.3,
strokeWidth: 2,
})
scene.addLayer(pointLayer);
scene.addLayer(pointLayer);
}); });

View File

@ -1,35 +1,31 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 0, pitch: 0,
type: 'amap', type: 'amap',
style: 'light', style: 'light',
center: [140.067171, 36.26186], center: [ 140.067171, 36.26186 ],
zoom: 5.32, zoom: 5.32,
maxZoom: 10 maxZoom: 10
}); });
fetch(
'https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json'
)
.then(res => res.json())
.then(data => {
const pointLayer = new PointLayer({})
.source(data)
.shape('circle')
.size('mag', [ 1, 25 ])
.color('mag', mag => {
return mag > 4.5 ? '#5B8FF9' : '#5CCEA1';
})
.style({
opacity: 0.3,
strokeWidth: 1
});
fetch('https://gw.alipayobjects.com/os/basement_prod/d3564b06-670f-46ea-8edb-842f7010a7c6.json') scene.addLayer(pointLayer);
.then((res) => res.json())
.then((data) => {
const pointLayer =
new PointLayer({
})
.source(data)
.shape('circle')
.size('mag', [1, 25])
.color('mag',(mag)=>{
return mag > 4.5? "#5B8FF9" : '#5CCEA1';
})
.style({
opacity: 0.3,
strokeWidth: 1
})
scene.addLayer(pointLayer);
}); });

View File

@ -1,43 +1,45 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
type: 'amap', type: 'amap',
style: 'light', style: 'light',
center: [-122.80009283836715, 37.05881309947238], center: [ -121.24357, 37.58264 ],
pitch: 0, pitch: 0,
zoom: 5.740491857794806 zoom: 6.45
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/6c4bb5f2-850b-419d-afc4-e46032fc9f94.csv') fetch(
.then((res) => res.text()) 'https://gw.alipayobjects.com/os/basement_prod/6c4bb5f2-850b-419d-afc4-e46032fc9f94.csv'
.then((data) => { )
const pointLayer = .then(res => res.text())
new PointLayer({ .then(data => {
const pointLayer = new PointLayer({})
.source(data, {
parser: {
type: 'csv',
x: 'Longitude',
y: 'Latitude'
}
}) })
.source(data,{ .shape('circle')
parser:{ .size(4)
type:'csv', .color('Magnitude', [
x:'Longitude', '#0A3663',
y:'Latitude' '#1558AC',
} '#3771D9',
}) '#4D89E5',
.shape('circle') '#64A5D3',
.size(4) '#72BED6',
.color('Magnitude',[ '#83CED6',
'#0A3663', '#1558AC', '#A6E1E0',
'#3771D9', '#4D89E5', '#B8EFE2',
'#64A5D3', '#72BED6', '#D7F9F0'
'#83CED6', '#A6E1E0', ])
'#B8EFE2', '#D7F9F0' .style({
]) opacity: 0.5,
.style({ strokeWidth: 0
opacity: 0.5, });
strokeWidth: 0,
})
scene.addLayer(pointLayer);
scene.addLayer(pointLayer);
}); });

View File

@ -1,33 +1,38 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 0, pitch: 0,
type: 'mapbox', type: 'mapbox',
style: 'dark', style: 'dark',
center: [ 96.99215001469588, 29.281597225674773], center: [ 96.99215001469588, 29.281597225674773 ],
zoom: 2.194613775109773, zoom: 2.194613775109773,
maxZoom: 10 maxZoom: 10
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/337ddbb7-aa3f-4679-ab60-d64359241955.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/337ddbb7-aa3f-4679-ab60-d64359241955.json'
.then((data) => { )
data.features = data.features.filter(item=>{ .then(res => res.json())
return item.properties.capacity> 800; .then(data => {
}) data.features = data.features.filter(item => {
const pointLayer = return item.properties.capacity > 800;
new PointLayer({ });
}) const pointLayer = new PointLayer({})
.source(data).shape('circle') .source(data)
.size('capacity', [0, 16]) .shape('circle')
.color('capacity',['#34B6B7', '#4AC5AF','#5FD3A6', '#7BE39E','#A1EDB8', '#CEF8D6']) .size('capacity', [ 0, 16 ])
.style({ .color('capacity', [
opacity: 0.5, '#34B6B7',
strokeWidth: 0 '#4AC5AF',
}) '#5FD3A6',
'#7BE39E',
scene.addLayer(pointLayer); '#A1EDB8',
'#CEF8D6'
])
.style({
opacity: 0.5,
strokeWidth: 0
});
scene.addLayer(pointLayer);
}); });

View File

@ -2,3 +2,4 @@
title: 气泡地图 title: 气泡地图
order: 0 order: 0
--- ---
指地图上可用一个形状相同、大小和与其代表的数值成固定比率的圆点符号来定位的点图层,用于表达离散现象分布特征的地图。

View File

@ -1,70 +1,78 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { Marker, Popup } from '@l7/component' import { Marker } from '@l7/component';
import * as G2 from '@antv/g2' import * as G2 from '@antv/g2';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
type: 'amap', type: 'amap',
style: 'light', style: 'light',
center: [2.6125016864608597,49.359131], center: [ 2.6125016864608597, 49.359131 ],
pitch: 0, pitch: 0,
zoom: 4.19 zoom: 4.19
}); });
scene.on('loaded',()=>{ scene.on('loaded', () => {
addChart(); addChart();
}) });
function addChart() { function addChart() {
fetch('https://gw.alipayobjects.com/os/basement_prod/0b96cca4-7e83-449a-93d0-2a77053e74ab.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/0b96cca4-7e83-449a-93d0-2a77053e74ab.json'
.then((data) => { )
data.nodes.forEach(function (item) { .then(res => res.json())
const el = document.createElement('div'); .then(data => {
const total = item.gdp.Agriculture + item.gdp.Industry + item.gdp.Service; data.nodes.forEach(function(item) {
const el = document.createElement('div');
const total =
item.gdp.Agriculture + item.gdp.Industry + item.gdp.Service;
const size = Math.min(parseInt(total / 30000), 70); const size = Math.min(parseInt(total / 30000, 10), 70);
if(size< 30) { if (size < 30) {
return return;
} }
console.log(total); const itemData = [
const itemData = [{ {
item: 'Agriculture', item: 'Agriculture',
count: item.gdp.Agriculture, count: item.gdp.Agriculture,
percent: item.gdp.Agriculture / total percent: item.gdp.Agriculture / total
}, { },
item: 'Industry', {
count: item.gdp.Industry, item: 'Industry',
percent: item.gdp.Industry / total count: item.gdp.Industry,
}, { percent: item.gdp.Industry / total
item: 'Service', },
count: item.gdp.Service, {
percent: item.gdp.Service / total item: 'Service',
}]; count: item.gdp.Service,
percent: item.gdp.Service / total
}
];
const chart = new G2.Chart({
const chart = new G2.Chart({ container: el,
container: el, width: size,
width: size, height: size,
height: size, render: 'svg',
render: 'svg', padding: 0
padding: 0, });
chart.legend(false);
chart.source(itemData);
chart.tooltip(false);
chart.axis('count', {
grid: false
});
chart
.interval()
.position('item*count')
.color('item', [ '#5CCEA1', '#5D7092', '#5B8FF9' ])
.opacity(1);
chart.render();
new Marker({
element: el
})
.setLnglat({
lng: item.coordinates[0],
lat: item.coordinates[1]
})
.addTo(scene);
}); });
chart.legend(false);
chart.source(itemData);
chart.tooltip(false);
chart.axis('count', {
grid:false
});
chart.interval().position('item*count').color('item',['#5CCEA1','#5D7092','#5B8FF9']).opacity(1);
chart.render();
new Marker({
element: el
}).setLnglat({
lng:item.coordinates[0],
lat:item.coordinates[1]
}).addTo(scene);
}); });
});
} }

View File

@ -1,91 +1,101 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { Marker, Popup } from '@l7/component' import { Marker } from '@l7/component';
import * as G2 from '@antv/g2' import * as G2 from '@antv/g2';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
type: 'amap', type: 'amap',
style: 'light', style: 'light',
center: [2.6125016864608597,49.359131], center: [ 2.6125016864608597, 49.359131 ],
pitch: 0, pitch: 0,
zoom: 4.19 zoom: 4.19
}); });
scene.on('loaded',()=>{ scene.on('loaded', () => {
addChart(); addChart();
}) });
window.mapScene = scene; window.mapScene = scene;
function addChart() { function addChart() {
fetch('https://gw.alipayobjects.com/os/basement_prod/0b96cca4-7e83-449a-93d0-2a77053e74ab.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/0b96cca4-7e83-449a-93d0-2a77053e74ab.json'
.then((data) => { )
data.nodes.forEach(function (item) { .then(res => res.json())
const el = document.createElement('div'); .then(data => {
const total = item.gdp.Agriculture + item.gdp.Industry + item.gdp.Service; data.nodes.forEach(function(item) {
const el = document.createElement('div');
const total =
item.gdp.Agriculture + item.gdp.Industry + item.gdp.Service;
const size = Math.min(parseInt(total / 30000), 70); const size = Math.min(parseInt(total / 30000, 10), 70);
if(size< 30) { if (size < 30) {
return return;
}
const itemData = [{
item: 'Agriculture',
count: item.gdp.Agriculture,
percent: item.gdp.Agriculture / total
}, {
item: 'Industry',
count: item.gdp.Industry,
percent: item.gdp.Industry / total
}, {
item: 'Service',
count: item.gdp.Service,
percent: item.gdp.Service / total
}];
var sliceNumber = 0.02;
// 自定义 other 的图形,增加两条线
G2.Shape.registerShape('interval', 'sliceShape', {
draw: function draw(cfg, container) {
var points = cfg.points;
var path = [];
path.push(['M', points[0].x, points[0].y]);
path.push(['L', points[1].x, points[1].y - sliceNumber]);
path.push(['L', points[2].x, points[2].y - sliceNumber]);
path.push(['L', points[3].x, points[3].y]);
path.push('Z');
path = this.parsePath(path);
return container.addShape('path', {
attrs: {
fill: cfg.color,
path: path
}
});
} }
}); const itemData = [
{
item: 'Agriculture',
count: item.gdp.Agriculture,
percent: item.gdp.Agriculture / total
},
{
item: 'Industry',
count: item.gdp.Industry,
percent: item.gdp.Industry / total
},
{
item: 'Service',
count: item.gdp.Service,
percent: item.gdp.Service / total
}
];
var chart = new G2.Chart({ const sliceNumber = 0.02;
container: el,
width: size, // 自定义 other 的图形,增加两条线
height: size, G2.Shape.registerShape('interval', 'sliceShape', {
render: 'svg', draw: function draw(cfg, container) {
padding: 0, const points = cfg.points;
let path = [];
path.push([ 'M', points[0].x, points[0].y ]);
path.push([ 'L', points[1].x, points[1].y - sliceNumber ]);
path.push([ 'L', points[2].x, points[2].y - sliceNumber ]);
path.push([ 'L', points[3].x, points[3].y ]);
path.push('Z');
path = this.parsePath(path);
return container.addShape('path', {
attrs: {
fill: cfg.color,
path
}
});
}
});
const chart = new G2.Chart({
container: el,
width: size,
height: size,
render: 'svg',
padding: 0
});
chart.legend(false);
chart.source(itemData);
chart.coord('theta', {
innerRadius: 0.6
});
chart.tooltip(false);
chart
.intervalStack()
.position('percent')
.color('item', [ '#5CCEA1', '#5D7092', '#5B8FF9' ])
.shape('sliceShape');
chart.render();
new Marker({
element: el
})
.setLnglat({
lng: item.coordinates[0],
lat: item.coordinates[1]
})
.addTo(scene);
}); });
chart.legend(false);
chart.source(itemData);
chart.coord('theta', {
innerRadius: 0.6
});
chart.tooltip(false);
chart.intervalStack().position('percent').color('item',['#5CCEA1','#5D7092','#5B8FF9']).shape('sliceShape');
chart.render();
new Marker({
element: el
}).setLnglat({
lng:item.coordinates[0],
lat:item.coordinates[1]
}).addTo(scene);
}); });
});
} }

View File

@ -1,6 +1,6 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { Marker, Popup } from '@l7/component' import { Marker } from '@l7/component';
import * as G2 from '@antv/g2' import * as G2 from '@antv/g2';
const CSS = `.l7-marker .g2-guide-html { const CSS = `.l7-marker .g2-guide-html {
width: 50px; width: 50px;
@ -21,16 +21,16 @@ l7-marker .g2-guide-html .value {
color: #000; color: #000;
font-weight: bold; font-weight: bold;
} }
` `;
function loadCssCode(code) { function loadCssCode(code) {
var style = document.createElement('style'); const style = document.createElement('style');
style.type = 'text/css'; style.type = 'text/css';
style.rel = 'stylesheet'; style.rel = 'stylesheet';
// for Chrome Firefox Opera Safari // for Chrome Firefox Opera Safari
style.appendChild(document.createTextNode(code)); style.appendChild(document.createTextNode(code));
// for IE // for IE
// style.styleSheet.cssText = code; // style.styleSheet.cssText = code;
var head = document.getElementsByTagName('head')[0]; const head = document.getElementsByTagName('head')[0];
head.appendChild(style); head.appendChild(style);
} }
loadCssCode(CSS); loadCssCode(CSS);
@ -40,40 +40,46 @@ const scene = new Scene({
pitch: 0, pitch: 0,
type: 'mapbox', type: 'mapbox',
style: 'dark', style: 'dark',
center: [52.21496184144132, 24.121126851768906], center: [ 52.21496184144132, 24.121126851768906 ],
zoom: 3.802, zoom: 3.802
}); });
window.mapScene = scene; window.mapScene = scene;
scene.on('loaded', () => { scene.on('loaded', () => {
Promise.all([ Promise.all([
fetch('https://gw.alipayobjects.com/os/antvdemo/assets/data/world.geo.json').then(d => d.json()), fetch(
fetch('https://gw.alipayobjects.com/os/basement_prod/5b772136-a1f4-4fc5-9a80-9f9974b4b182.json').then(d => d.json()), 'https://gw.alipayobjects.com/os/basement_prod/5b772136-a1f4-4fc5-9a80-9f9974b4b182.json'
fetch('https://gw.alipayobjects.com/os/basement_prod/f3c467a4-9ae0-4f08-bb5f-11f9c869b2cb.json').then(d => d.json()) ).then(d => d.json()),
]).then(function onLoad([world, center, population]) { fetch(
'https://gw.alipayobjects.com/os/basement_prod/f3c467a4-9ae0-4f08-bb5f-11f9c869b2cb.json'
).then(d => d.json())
]).then(function onLoad([ center, population ]) {
const popobj = {}; const popobj = {};
population.forEach(element => { population.forEach(element => {
popobj[element.Code] = element['Population, female (% of total) (% of total)'] popobj[element.Code] =
element['Population, female (% of total) (% of total)'];
}); });
// 数据绑定 // 数据绑定
center.features = center.features.map((fe) => { center.features = center.features.map(fe => {
fe.properties.female = popobj[fe.properties.id] * 1 || 0; fe.properties.female = popobj[fe.properties.id] * 1 || 0;
return fe; return fe;
}) });
center.features.forEach((point, index) => { center.features.forEach(point => {
const el = document.createElement('div'); const el = document.createElement('div');
const coord = point.geometry.coordinates; const coord = point.geometry.coordinates;
const v = point.properties.female * 1; const v = point.properties.female * 1;
if (v < 1 || v> 46 && v < 54) return; if (v < 1 || (v > 46 && v < 54)) { return; }
const size = 60; const size = 60;
const data = [{ const data = [
type: '男性', {
value: 100.00 - v.toFixed(2) type: '男性',
}, { value: 100.0 - v.toFixed(2)
type: '女性', },
value: v.toFixed(2) * 1 {
}]; type: '女性',
value: v.toFixed(2) * 1
}
];
const chart = new G2.Chart({ const chart = new G2.Chart({
container: el, container: el,
width: size, width: size,
@ -88,15 +94,18 @@ scene.on('loaded', () => {
radius: 0.9, radius: 0.9,
innerRadius: 0.6 innerRadius: 0.6
}); });
chart.intervalStack().position('value').color('type', ['#5CCEA1','#5B8FF9']).opacity(1); chart
.intervalStack()
.position('value')
.color('type', [ '#5CCEA1', '#5B8FF9' ])
.opacity(1);
chart.render(); chart.render();
new Marker( new Marker({ element: el })
{ element: el} .setLnglat({
).setLnglat({ lng: coord[0],
lng: coord[0], lat: coord[1]
lat: coord[1] })
}).addTo(scene); .addTo(scene);
}) });
}); });
}) });

View File

@ -2,3 +2,4 @@
title: 复合图表地图 title: 复合图表地图
order: 6 order: 6
--- ---
使用二维统计图表代替点状符号的一种特殊复合形式,复合图表地图中常用扩展图形还有柱状图、曲线图、玫瑰图等

View File

@ -1,40 +1,42 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 65.68421052631578, pitch: 66.02383,
type: 'amap', type: 'amap',
style: 'dark', style: 'dark',
center: [121.3917, 31.259242], center: [ 121.400257, 31.25287 ],
zoom: 14.55, zoom: 14.55,
rotation: 120 rotation: 134.9507
}); });
window.mapScene = scene; window.mapScene = scene;
fetch('https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json'
.then((data) => { )
const pointLayer = .then(res => res.json())
new PointLayer({ .then(data => {
const pointLayer = new PointLayer({})
.source(data, {
parser: {
type: 'json',
x: 'longitude',
y: 'latitude'
}
}) })
.source(data, { .shape('name', [
parser: { 'cylinder',
type: 'json', 'triangleColumn',
x: 'longitude', 'hexagonColumn',
y: 'latitude' 'squareColumn'
} ])
}).shape('name', ['cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn']) .size('unit_price', h => {
.size('unit_price', (h) => { return [ 6, 6, h / 500 ];
return [6, 6, h / 500] })
}) .color('name', [ '#739DFF', '#61FCBF', '#FFDE74', '#FF896F' ])
.color('name', ['#739DFF', "#61FCBF", '#FFDE74', '#FF896F']) .style({
.style({ opacity: 1.0
opacity: 1.0, });
})
scene.addLayer(pointLayer); scene.addLayer(pointLayer);
}); });

View File

@ -1,40 +1,42 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 65.68421052631578, pitch: 60,
type: 'mapbox', type: 'mapbox',
style: 'light', style: 'light',
center: [121.3917, 31.259242], center: [ 121.412224, 31.26192438 ],
zoom: 13.55, zoom: 13.13438,
rotation: 120 rotation: 35.97133
}); });
window.mapScene = scene; window.mapScene = scene;
fetch('https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json'
.then((data) => { )
const pointLayer = .then(res => res.json())
new PointLayer({ .then(data => {
const pointLayer = new PointLayer({})
.source(data, {
parser: {
type: 'json',
x: 'longitude',
y: 'latitude'
}
}) })
.source(data, { .shape('name', [
parser: { 'cylinder',
type: 'json', 'triangleColumn',
x: 'longitude', 'hexagonColumn',
y: 'latitude' 'squareColumn'
} ])
}).shape('name', ['cylinder', 'triangleColumn', 'hexagonColumn', 'squareColumn']) .size('unit_price', h => {
.size('unit_price', (h) => { return [ 6, 6, h / 500 ];
return [6, 6, h / 500] })
}) .color('name', [ '#5B8FF9', '#70E3B5', '#FFD458', '#FF7C6A' ])
.color('name', ['#5B8FF9', "#70E3B5", '#FFD458', '#FF7C6A']) .style({
.style({ opacity: 1.0
opacity: 1.0, });
})
scene.addLayer(pointLayer); scene.addLayer(pointLayer);
}); });

View File

@ -1,44 +1,44 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 35.210526315789465, pitch: 35.210526315789465,
type: 'amap', type: 'amap',
style: 'dark', style: 'dark',
center: [108.524505, 29.873128], center: [ 104.288144, 31.239692 ],
zoom: 4.4, zoom: 4.4
}); });
window.mapScene = scene; window.mapScene = scene;
fetch('https://gw.alipayobjects.com/os/rmsportal/oVTMqfzuuRFKiDwhPSFL.json') fetch('https://gw.alipayobjects.com/os/rmsportal/oVTMqfzuuRFKiDwhPSFL.json')
.then((res) => res.json()) .then(res => res.json())
.then((data) => { .then(data => {
const pointLayer = const pointLayer = new PointLayer({})
new PointLayer({ .source(data.list, {
parser: {
type: 'json',
x: 'j',
y: 'w'
}
}) })
.source(data.list, { .shape('cylinder')
parser: { .size('t', function(level) {
type: 'json', return [ 1, 2, level * 2 + 20 ];
x: 'j', })
y: 'w' .color('t', [
} '#094D4A',
}) '#146968',
.shape('cylinder') '#1D7F7E',
.size('t', function (level) { '#289899',
return [1, 2, level * 2 + 20]; '#34B6B7',
}) '#4AC5AF',
.color('t', [ '#5FD3A6',
'#094D4A', '#146968', '#7BE39E',
'#1D7F7E', '#289899', '#A1EDB8',
'#34B6B7', '#4AC5AF', '#CEF8D6'
'#5FD3A6', '#7BE39E', ])
'#A1EDB8', '#CEF8D6' .style({
]) opacity: 1.0
.style({ });
opacity: 1.0,
})
scene.addLayer(pointLayer); scene.addLayer(pointLayer);
console.log(pointLayer); });
});

View File

@ -1,38 +1,33 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 35.210526315789465, pitch: 48.62562,
type: 'amap', type: 'amap',
style: 'light', style: 'light',
center: [108.524505, 29.873128], center: [ 104.026043, 31.847 ],
zoom: 4.4, rotation: -0.76,
zoom: 4.48
}); });
window.mapScene = scene; window.mapScene = scene;
fetch('https://gw.alipayobjects.com/os/rmsportal/oVTMqfzuuRFKiDwhPSFL.json') fetch('https://gw.alipayobjects.com/os/rmsportal/oVTMqfzuuRFKiDwhPSFL.json')
.then((res) => res.json()) .then(res => res.json())
.then((data) => { .then(data => {
const pointLayer = const pointLayer = new PointLayer({})
new PointLayer({ .source(data.list, {
parser: {
type: 'json',
x: 'j',
y: 'w'
}
}) })
.source(data.list, { .shape('cylinder')
parser: { .size('t', function(level) {
type: 'json', return [ 1, 2, level * 2 + 20 ];
x: 'j', })
y: 'w' .color('#006CFF')
} .style({
}) opacity: 1.0
.shape('cylinder') });
.size('t', function (level) {
return [1, 2, level * 2 + 20];
})
.color('#006CFF')
.style({
opacity: 1.0,
})
scene.addLayer(pointLayer); scene.addLayer(pointLayer);
console.log(pointLayer); });
});

View File

@ -2,3 +2,4 @@
title: 3D 柱状地图 title: 3D 柱状地图
order: 4 order: 4
--- ---
用形状大小相同的柱状体代替点状符号,高度与数值大小映射共同表达离散现象分布特征的地图

View File

@ -1,29 +1,30 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
console.log(this);
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 0, pitch: 0,
type: 'amap', type: 'amap',
style: 'light', style: 'light',
center: [121.434765, 31.256735], center: [ 121.434765, 31.256735 ],
zoom: 14.83, zoom: 14.83
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9140d288ae.json'
.then((data) => { )
.then(res => res.json())
.then(data => {
scene.addImage( scene.addImage(
'00', '00',
'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg', 'https://gw.alipayobjects.com/zos/basement_prod/604b5e7f-309e-40db-b95b-4fac746c5153.svg'
); );
scene.addImage( scene.addImage(
'01', '01',
'https://gw.alipayobjects.com/zos/basement_prod/30580bc9-506f-4438-8c1a-744e082054ec.svg', 'https://gw.alipayobjects.com/zos/basement_prod/30580bc9-506f-4438-8c1a-744e082054ec.svg'
); );
scene.addImage( scene.addImage(
'02', '02',
'https://gw.alipayobjects.com/zos/basement_prod/7aa1f460-9f9f-499f-afdf-13424aa26bbf.svg', 'https://gw.alipayobjects.com/zos/basement_prod/7aa1f460-9f9f-499f-afdf-13424aa26bbf.svg'
); );
const imageLayer = new PointLayer() const imageLayer = new PointLayer()
.source(data, { .source(data, {
@ -33,9 +34,7 @@ fetch('https://gw.alipayobjects.com/os/basement_prod/893d1d5f-11d9-45f3-8322-ee9
y: 'latitude' y: 'latitude'
} }
}) })
.shape('name', ['00', '01', '02']) .shape('name', [ '00', '01', '02' ])
.size(20); .size(20);
scene.addLayer(imageLayer); scene.addLayer(imageLayer);
}); });

View File

@ -1,28 +1,26 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 0, pitch: 0,
type: 'amap', type: 'amap',
style: 'light', style: 'light',
center: [116.276227, 35.256776], center: [ 116.276227, 35.256776 ],
zoom: 6, zoom: 6
}); });
fetch('https://gw.alipayobjects.com/os/basement_prod/e2fc6e0a-af2a-4320-96e5-d9f5a5fda442.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/e2fc6e0a-af2a-4320-96e5-d9f5a5fda442.json'
.then((data) => { )
.then(res => res.json())
.then(data => {
scene.addImage( scene.addImage(
'marker', 'marker',
'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*BJ6cTpDcuLcAAAAAAAAAAABkARQnAQ', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*BJ6cTpDcuLcAAAAAAAAAAABkARQnAQ'
); );
const imageLayer = new PointLayer() const imageLayer = new PointLayer()
.source(data) .source(data)
.shape('marker') .shape('marker')
.size(12); .size(12);
scene.addLayer(imageLayer); scene.addLayer(imageLayer);
}); });

View File

@ -1,37 +1,72 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
type: 'amap', type: 'amap',
style: 'dark', style: 'dark',
center: [120.5969, 29.7918], center: [ 120.5969, 29.7918 ],
pitch: 35, pitch: 35,
zoom: 7, zoom: 7,
rotation: 4.183582 rotation: 4.183582
}); });
scene.addImage('00', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*kzTMQqS2QdUAAAAAAAAAAABkARQnAQ'); scene.addImage(
scene.addImage('01', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*jH1XRb7F7hMAAAAAAAAAAABkARQnAQ'); '00',
scene.addImage('02', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*YaKSTr3L5i8AAAAAAAAAAABkARQnAQ'); 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*kzTMQqS2QdUAAAAAAAAAAABkARQnAQ'
scene.addImage('04', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*dmniQrDpCYwAAAAAAAAAAABkARQnAQ'); );
scene.addImage('11', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*YaKSTr3L5i8AAAAAAAAAAABkARQnAQ'); scene.addImage(
scene.addImage('15', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*YNlXQYCIzroAAAAAAAAAAABkARQnAQ'); '01',
scene.addImage('07', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*DccRTI6ZRLoAAAAAAAAAAABkARQnAQ'); 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*jH1XRb7F7hMAAAAAAAAAAABkARQnAQ'
scene.addImage('16', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*iQKoS6I-rO8AAAAAAAAAAABkARQnAQ'); );
scene.addImage('06', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*f-wyS7ad5p0AAAAAAAAAAABkARQnAQ'); scene.addImage(
scene.addImage('08', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*lHhzQrOW4AQAAAAAAAAAAABkARQnAQ'); '02',
scene.addImage('17', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*9Q0QS4GdaYcAAAAAAAAAAABkARQnAQ'); 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*YaKSTr3L5i8AAAAAAAAAAABkARQnAQ'
scene.addImage('05', 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*LyuVRowl6nAAAAAAAAAAAABkARQnAQ'); );
fetch('https://gw.alipayobjects.com/os/basement_prod/c6042c6b-45fd-4e2e-adf8-fdbf060441e8.json') scene.addImage(
.then((res) => res.json()) '04',
.then((data) => { 'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*dmniQrDpCYwAAAAAAAAAAABkARQnAQ'
);
scene.addImage(
'11',
'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*YaKSTr3L5i8AAAAAAAAAAABkARQnAQ'
);
scene.addImage(
'15',
'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*YNlXQYCIzroAAAAAAAAAAABkARQnAQ'
);
scene.addImage(
'07',
'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*DccRTI6ZRLoAAAAAAAAAAABkARQnAQ'
);
scene.addImage(
'16',
'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*iQKoS6I-rO8AAAAAAAAAAABkARQnAQ'
);
scene.addImage(
'06',
'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*f-wyS7ad5p0AAAAAAAAAAABkARQnAQ'
);
scene.addImage(
'08',
'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*lHhzQrOW4AQAAAAAAAAAAABkARQnAQ'
);
scene.addImage(
'17',
'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*9Q0QS4GdaYcAAAAAAAAAAABkARQnAQ'
);
scene.addImage(
'05',
'https://gw.alipayobjects.com/mdn/antv_site/afts/img/A*LyuVRowl6nAAAAAAAAAAAABkARQnAQ'
);
fetch(
'https://gw.alipayobjects.com/os/basement_prod/c6042c6b-45fd-4e2e-adf8-fdbf060441e8.json'
)
.then(res => res.json())
.then(data => {
const imageLayer = new PointLayer() const imageLayer = new PointLayer()
.source(data) .source(data)
.shape('w', function (w) { .shape('w', function(w) {
return w; return w;
}) })
.size(15) .size(15);
scene.addLayer(imageLayer); scene.addLayer(imageLayer);
}); });

View File

@ -2,3 +2,4 @@
title: 符号地图 title: 符号地图
order: 2 order: 2
--- ---
以形状变量中具象的图标映射的点图层,将真实地物具化为利于直观识别的图标,常用于突出信息的突出表达。

View File

@ -1,40 +1,54 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { Marker } from '@l7/component' import { Marker } from '@l7/component';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
type: 'amap', type: 'amap',
style: 'light', style: 'light',
center: [110.80009283836715, 37.05881309947238], center: [ 105.790327, 36.495636 ],
pitch: 0, pitch: 0,
zoom: 4 zoom: 4
}); });
scene.on('loaded',()=>{ scene.on('loaded', () => {
addMarkers(); addMarkers();
}) });
function addMarkers() { function addMarkers() {
fetch('https://gw.alipayobjects.com/os/basement_prod/67f47049-8787-45fc-acfe-e19924afe032.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/67f47049-8787-45fc-acfe-e19924afe032.json'
.then((nodes) => { )
for (var i = 0; i < nodes.length; i++) { .then(res => res.json())
.then(nodes => {
if (nodes[i].g !== '1' || nodes[i].v === '') continue; for (let i = 0; i < nodes.length; i++) {
console.log(nodes[i],nodes[i].v === '') if (nodes[i].g !== '1' || nodes[i].v === '') { continue; }
var el = document.createElement('label'); const el = document.createElement('label');
el.className = 'lableclass'; el.className = 'lableclass';
el.textContent = nodes[i].v +'℃'; el.textContent = nodes[i].v + '℃';
el.style.background = getColor(nodes[i].v); el.style.background = getColor(nodes[i].v);
el.style.borderColor = getColor(nodes[i].v); el.style.borderColor = getColor(nodes[i].v);
const marker = new Marker({ new Marker({
element: el element: el
}).setLnglat({ lng: nodes[i].x * 1, lat: nodes[i].y }) })
.addTo(scene);; .setLnglat({ lng: nodes[i].x * 1, lat: nodes[i].y })
.addTo(scene);
} }
}) });
} }
function getColor(v) { function getColor(v) {
return v > 50 ? '#800026' : v > 40 ? '#BD0026' : v > 30 ? '#E31A1C' : v > 20 ? '#FC4E2A' : v > 10 ? '#FD8D3C' : v > 5 ? '#FEB24C' : v > 0 ? '#FED976' : '#FFEDA0'; return v > 50
} ? '#800026'
: v > 40
? '#BD0026'
: v > 30
? '#E31A1C'
: v > 20
? '#FC4E2A'
: v > 10
? '#FD8D3C'
: v > 5
? '#FEB24C'
: v > 0
? '#FED976'
: '#FFEDA0';
}

View File

@ -2,3 +2,4 @@
title: 自定义 Marker title: 自定义 Marker
order: 7 order: 7
--- ---
可自定义点符号通过自定义dom实现地图标注富文本、动态点状符号都可用于地图上信息的标记。

View File

@ -1,34 +1,30 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
type: 'amap', type: 'amap',
style: 'dark', style: 'dark',
center: [121.417463, 31.215175], center: [ 121.417463, 31.215175 ],
pitch: 0, pitch: 0,
zoom: 11 zoom: 11
}); });
window.mapScene = scene; window.mapScene = scene;
fetch('https://gw.alipayobjects.com/os/rmsportal/BElVQFEFvpAKzddxFZxJ.txt') fetch('https://gw.alipayobjects.com/os/rmsportal/BElVQFEFvpAKzddxFZxJ.txt')
.then((res) => res.text()) .then(res => res.text())
.then((data) => { .then(data => {
const pointLayer = const pointLayer = new PointLayer({})
new PointLayer({
})
.source(data, { .source(data, {
parser: { parser: {
type: 'csv', type: 'csv',
y: 'lat', y: 'lat',
x: 'lng' x: 'lng'
} }
}).size(0.5) })
.size(0.5)
.color('#080298') .color('#080298')
.style({ .style({
opacity:1., opacity: 1
}) });
scene.addLayer(pointLayer); scene.addLayer(pointLayer);
});
})

View File

@ -1,36 +1,37 @@
import { Scene } from '@l7/scene'; import { Scene } from '@l7/scene';
import { PointLayer } from '@l7/layers' import { PointLayer } from '@l7/layers';
const scene = new Scene({ const scene = new Scene({
id: 'map', id: 'map',
pitch: 64.88, pitch: 64.88,
type: 'amap', type: 'amap',
style: 'dark', style: 'dark',
center: [114.060288, 22.53684], center: [ 114.060288, 22.53684 ],
zoom: 15.63, zoom: 15.63
}); });
window.mapScene = scene; window.mapScene = scene;
fetch('https://gw.alipayobjects.com/os/basement_prod/513add53-dcb2-4295-8860-9e7aa5236699.json') fetch(
.then((res) => res.json()) 'https://gw.alipayobjects.com/os/basement_prod/513add53-dcb2-4295-8860-9e7aa5236699.json'
.then((data) => { )
const pointLayer = .then(res => res.json())
new PointLayer({ .then(data => {
const pointLayer = new PointLayer({})
}) .source(data)
.source(data) .size(2)
.size(2) .color('h8', [
.color('h8',[ '#0A3663',
'#0A3663', '#1558AC', '#1558AC',
'#3771D9', '#4D89E5', '#3771D9',
'#64A5D3', '#72BED6', '#4D89E5',
'#83CED6', '#A6E1E0', '#64A5D3',
'#B8EFE2', '#D7F9F0' '#72BED6',
]) '#83CED6',
.style({ '#A6E1E0',
opacity:1., '#B8EFE2',
}) '#D7F9F0'
])
.style({
opacity: 1
});
scene.addLayer(pointLayer); scene.addLayer(pointLayer);
});
})

Some files were not shown because too many files have changed in this diff Show More