mirror of https://gitee.com/antv-l7/antv-l7
chore: add ChatGPT action (#1589)
* docs: add 行政区demo * fix: lint error * docs: scale 文档更新 * docs: marker demo& chatgpt ci * chore: update chatgpt workflows * chore: update ci config
This commit is contained in:
parent
f863001e9d
commit
54c43d6dd4
|
@ -0,0 +1,19 @@
|
|||
on: [pull_request]
|
||||
|
||||
name: ChatGPT CodeReview
|
||||
|
||||
jobs:
|
||||
hello_world_job:
|
||||
runs-on: ubuntu-latest
|
||||
name: ChatGPT explain code
|
||||
steps:
|
||||
- name: ChatGTP explain code
|
||||
uses: cirolini/chatgpt-github-actions@v1.3
|
||||
with:
|
||||
openai_api_key: ${{ secrets.CHATGPT_SESSION_TOKEN }}
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
github_pr_id: ${{ github.event.number }}
|
||||
openai_engine: "text-davinci-002" #optional
|
||||
openai_temperature: 0.5 #optional
|
||||
openai_max_tokens: 2048 #optional
|
||||
mode: patch # file or patch git
|
|
@ -1,5 +1,5 @@
|
|||
import { Scene,PointLayer,Marker } from '@antv/l7';
|
||||
import { DrawPoint,DrawEvent } from '@antv/l7-draw';
|
||||
import { Marker, PointLayer, Scene } from '@antv/l7';
|
||||
import { DrawEvent, DrawPoint } from '@antv/l7-draw';
|
||||
import { Mapbox } from '@antv/l7-maps';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
|
@ -12,54 +12,52 @@ const Demo: React.FC = () => {
|
|||
const scene = new Scene({
|
||||
id,
|
||||
map: new Mapbox({
|
||||
center: [
|
||||
116.39153415221631,
|
||||
39.90678816789074
|
||||
],
|
||||
center: [116.39153415221631, 39.90678816789074],
|
||||
pitch: 0,
|
||||
style: 'mapbox://styles/mapbox/streets-v12',
|
||||
zoom: 22,
|
||||
token:
|
||||
"pk.eyJ1IjoibW9ob25nIiwiYSI6ImNrNGFsdjY5ZzA1NW4zbG14b2JoMnA5c3IifQ.1qVWFsyHW2wKThTgQg08SA"
|
||||
'pk.eyJ1IjoibW9ob25nIiwiYSI6ImNrNGFsdjY5ZzA1NW4zbG14b2JoMnA5c3IifQ.1qVWFsyHW2wKThTgQg08SA',
|
||||
}),
|
||||
});
|
||||
|
||||
scene.on('loaded', () => {
|
||||
const point = new PointLayer().source({
|
||||
"type": "FeatureCollection",
|
||||
"features": [
|
||||
const point = new PointLayer()
|
||||
.source({
|
||||
type: 'FeatureCollection',
|
||||
features: [
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"coordinates": [
|
||||
116.39153415221631,
|
||||
39.90678816789074
|
||||
type: 'Feature',
|
||||
properties: {},
|
||||
geometry: {
|
||||
coordinates: [116.39153415221631, 39.90678816789074],
|
||||
type: 'Point',
|
||||
},
|
||||
},
|
||||
],
|
||||
"type": "Point"
|
||||
}
|
||||
}
|
||||
]
|
||||
}).color('red')
|
||||
})
|
||||
.color('red')
|
||||
.shape('circle')
|
||||
.size(5);
|
||||
|
||||
const marker = new Marker().setLnglat({ lng:116.39153415221631, lat: 39.90678816789074 });
|
||||
const marker = new Marker().setLnglat({
|
||||
lng: 116.39153415221631,
|
||||
lat: 39.90678816789074,
|
||||
});
|
||||
scene.addMarker(marker);
|
||||
scene.addLayer(point)
|
||||
scene.addLayer(point);
|
||||
const drawer = new DrawPoint(scene, {
|
||||
// liveUpdate: true,
|
||||
});
|
||||
scene.on('zoomend',()=>{
|
||||
console.log(scene.getZoom())
|
||||
})
|
||||
scene.on('zoomend', () => {
|
||||
console.log(scene.getZoom());
|
||||
});
|
||||
|
||||
setLineDrawer(drawer);
|
||||
drawer.enable();
|
||||
drawer.on(DrawEvent.Add, (newPoint, pointList) => {
|
||||
console.log('add', newPoint, pointList);
|
||||
});
|
||||
|
||||
});
|
||||
}, []);
|
||||
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import { Scene, Marker } from '@antv/l7';
|
||||
import { GaodeMap } from '@antv/l7-maps';
|
||||
|
||||
const scene = new Scene({
|
||||
id: 'map',
|
||||
map: new GaodeMap({
|
||||
style: 'light',
|
||||
center: [ 105.790327, 36.495636 ],
|
||||
zoom: 4
|
||||
})
|
||||
});
|
||||
scene.on('loaded', () => {
|
||||
addMarkers();
|
||||
scene.render();
|
||||
});
|
||||
function addMarkers() {
|
||||
fetch(
|
||||
'https://gw.alipayobjects.com/os/basement_prod/67f47049-8787-45fc-acfe-e19924afe032.json'
|
||||
)
|
||||
.then(res => res.json())
|
||||
.then(nodes => {
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
if (nodes[i].g !== '1' || nodes[i].v === '') {
|
||||
continue;
|
||||
}
|
||||
|
||||
const marker = new Marker().setLnglat({ lng: nodes[i].x * 1, lat: nodes[i].y });
|
||||
scene.addMarker(marker);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
@ -4,6 +4,12 @@
|
|||
"en": "Category"
|
||||
},
|
||||
"demos": [
|
||||
{
|
||||
"filename": "defaultmarker.js",
|
||||
"title": "默认 Marker",
|
||||
"screenshot":"https://mdn.alipayobjects.com/afts/img/A*Lwx2RoaXjmwAAAAAAAAAAAAADrd2AQ/20230207225205.jpg"
|
||||
|
||||
},
|
||||
{
|
||||
"filename": "markerlayer.js",
|
||||
"title": "MarkerLayer 统一管理Marker",
|
||||
|
|
|
@ -29,11 +29,6 @@
|
|||
"filename": "turin.js",
|
||||
"title": "都灵道路图",
|
||||
"screenshot":"https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*P1o6R7jm0JsAAAAAAAAAAAAAARQnAQ"
|
||||
},
|
||||
{
|
||||
"filename": "timeline.js",
|
||||
"title": "公交站点时序数据",
|
||||
"screenshot":"https://gw.alipayobjects.com/mdn/rms_816329/afts/img/A*l2YoR56mK1EAAAAAAAAAAAAAARQnAQ"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,117 +0,0 @@
|
|||
import { Scene, PointLayer } from '@antv/l7';
|
||||
import { GaodeMap } from '@antv/l7-maps';
|
||||
const currentTimeKey = '0000';
|
||||
let timeKeys = [];
|
||||
let wrap = null;
|
||||
let layer = null;
|
||||
const modelDatas = {};
|
||||
const parser = {
|
||||
parser: {
|
||||
type: 'json',
|
||||
x: 'o',
|
||||
y: 'a'
|
||||
}
|
||||
};
|
||||
insetDom();
|
||||
const scene = new Scene({
|
||||
id: 'map',
|
||||
map: new GaodeMap({
|
||||
center: [ 120.2, 36.1 ],
|
||||
zoom: 10,
|
||||
style: 'dark'
|
||||
})
|
||||
});
|
||||
scene.on('loaded', () => {
|
||||
|
||||
fetch(
|
||||
'https://gw.alipayobjects.com/os/bmw-prod/82d85bb6-db7c-4583-af26-35b11c7b2d0d.json'
|
||||
)
|
||||
.then(res => res.json())
|
||||
.then(originData => {
|
||||
timeKeys = Object.keys(originData);
|
||||
|
||||
layer = new PointLayer({})
|
||||
.source(originData[currentTimeKey], parser)
|
||||
.shape('simple')
|
||||
.size('v', v => Math.sqrt(v) / 5)
|
||||
.color('v', [
|
||||
'#ffffb2',
|
||||
'#fed976',
|
||||
'#feb24c',
|
||||
'#fd8d3c',
|
||||
'#f03b20',
|
||||
'#bd0026'
|
||||
])
|
||||
.style({
|
||||
opacity: 0.6
|
||||
});
|
||||
|
||||
scene.addLayer(layer);
|
||||
|
||||
layer.on('modelLoaded', () => {
|
||||
getModelDatas(originData);
|
||||
|
||||
run();
|
||||
});
|
||||
|
||||
return '';
|
||||
});
|
||||
return '';
|
||||
});
|
||||
|
||||
function run() {
|
||||
let count = 0;
|
||||
const timer = setInterval(() => {
|
||||
if (count > 47) {
|
||||
clearInterval(timer);
|
||||
}
|
||||
|
||||
const key = getTimeKey(count, '');
|
||||
const key2 = getTimeKey(count, ':');
|
||||
const data = modelDatas[key];
|
||||
if (layer && scene && data) {
|
||||
layer.updateModelData(data);
|
||||
wrap.innerHTML = key2;
|
||||
scene.render();
|
||||
}
|
||||
|
||||
count++;
|
||||
}, 300);
|
||||
}
|
||||
|
||||
function getModelDatas(originData) {
|
||||
timeKeys.map(timeKey => {
|
||||
modelDatas[timeKey] = layer.createModelData(originData[timeKey], parser);
|
||||
return '';
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function insetDom() {
|
||||
const mapContrainer = document.getElementById('map');
|
||||
wrap = document.createElement('div');
|
||||
wrap.style.zIndex = 10;
|
||||
wrap.style.position = 'absolute';
|
||||
wrap.style.top = '50px';
|
||||
wrap.style.left = '5%';
|
||||
wrap.style.right = '5%';
|
||||
wrap.style.color = '#fff';
|
||||
wrap.style.fontSize = '18px';
|
||||
wrap.innerHTML = '00:00';
|
||||
mapContrainer.appendChild(wrap);
|
||||
}
|
||||
|
||||
function getTimeKey(time, text) {
|
||||
const half = Math.floor(time / 2);
|
||||
let res = '';
|
||||
if (half < 10) {
|
||||
res += '0';
|
||||
}
|
||||
if (time / 2 > half) {
|
||||
res += half + text + '30';
|
||||
} else {
|
||||
res += half + text + '00';
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
Loading…
Reference in New Issue