This commit is contained in:
thinkinggis 2019-03-01 14:54:05 +08:00
parent a8326dcc0e
commit 69d280f421
10 changed files with 116 additions and 207 deletions

View File

@ -1,77 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="geometry" content="diagram">
<link rel="stylesheet" href="./assets/common.css">
<link rel="stylesheet" href="./assets/info.css">
<title>point_circle</title>
<style>
#map { position:absolute; top:0; bottom:0; width:100%; }
.amap-maps {
cursor: auto !important
}
</style>
</head>
<body>
<div id="map"></div>
<script src="https://webapi.amap.com/maps?v=1.4.8&key=15cd8a57710d40c9b7c0e3cc120f1200&plugin=Map3D"></script>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="./assets/dat.gui.min.js"></script>
<script src="../build/L7.js"></script>
<script>
const colorObj ={
blue: ["#E8FCFF", "#CFF6FF", "#A1E9ff", "#65CEF7", "#3CB1F0", "#2894E0", "#1772c2", "#105CB3", "#0D408C", "#002466"].reverse(),
red: ["#FFF4F2", "#FFDFDB", "#FAADAA", "#F77472", "#F04850", "#D63147", "#BD223E", "#A81642", "#820C37", "#5C0023"].reverse(),
orange:["#FFF7EB", "#FFECD4", "#FAD09D", "#F7B16A", "#F08D41", "#DB6C2C", "#C2491D", "#AD2B11", "#871D0C", "#610800"].reverse(),
green:["#FAFFF0", "#EBF7D2", "#C8E695", "#A5D660", "#7DC238", "#59A616", "#3F8C0B", "#237804", "#125200", "#082B00"].reverse(),
yellow:["#FFFFE8", "#FFFECC", "#FAF896", "#F7E463", "#F0CE3A", "#DBB125", "#C29117", "#AD7410", "#87500C", "#613000"].reverse(),
purple:["#FCF2FF", "#F5DEFF", "#DDB3F2", "#BE7BE3", "#9B4ECF", "#7737B3", "#5B2899", "#411C85", "#270F5E", "#100338"].reverse()
}
const scene = new L7.Scene({
id: 'map',
mapStyle: 'light', // 样式URL
center: [ 120.19382669582967, 30.258134 ],
pitch: 0,
zoom: 4,
maxZoom:14,
minZoom:4,
});
window.scene = scene;
scene.on('loaded', () => {
$.get('https://gw.alipayobjects.com/os/basement_prod/7359a5e9-3c5e-453f-b207-bc892fb23b84.csv', data => {
const circleLayer = scene.PointLayer({
zIndex: 2
})
.source(data,{
type: 'csv',
x: 'lng',
y: 'lat',
})
.size(1.0)
.color('#0D408C')
.style({
stroke: 'rgb(255,255,255)',
strokeWidth: 1,
opacity: 1.
})
.render();
circleLayer.on('click',(e)=>{
console.log(e);
})
});
});
</script>
</body>
</html>

View File

@ -1,63 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="geometry" content="diagram">
<link rel="stylesheet" href="./assets/common.css">
<title>point_circle</title>
<style>
#map { position:absolute; top:0; bottom:0; width:100%; }
</style>
</head>
<body>
<div id="map"></div>
<script src="https://webapi.amap.com/maps?v=1.4.8&key=15cd8a57710d40c9b7c0e3cc120f1200&plugin=Map3D"></script>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="./assets/dat.gui.min.js"></script>
<script src="../build/L7.js"></script>
<script>
const scene = new L7.Scene({
id: 'map',
mapStyle: 'dark', // 样式URL
center: [ 120.037828998113099, 30.086317611850635 ],
pitch: 0,
zoom: 5.44
});
window.scene = scene;
var colorObj={
'黄色':'yellow',
'蓝色':'blue',
'橙色':'orange'
}
scene.on('loaded', () => {
$.get('./data/waringData.json', data => {
scene.PointLayer({
zIndex: 2
})
.source(data, {
type: 'array',
x: 'lon',
y: 'lat',
})
.shape('2d:radar')
.size(80 )
.active(false)
.color('signallevel',(v)=>{
return colorObj[v];
})
.style({
shape:'radar'
})
.render();
});
});
</script>
</body>
</html>

View File

@ -48,15 +48,21 @@
"open": "~0.0.5",
"parseurl": "~1.3.2",
"pre-commit": "~1.2.2",
"rollup-plugin-buble": "^0.19.6",
"rollup-plugin-commonjs": "^9.2.1",
"rollup-plugin-node-resolve": "^4.0.1",
"rollup-plugin-terser": "^4.0.4",
"serve-static": "^1.13.2",
"shelljs": "~0.7.8",
"string-replace-loader": "~1.3.0",
"torchjs": "~2.1.0",
"uglify-js": "~3.1.10",
"webpack": "~3.10.0",
"webpack": "~4.29.6",
"worker-loader": "^2.0.0"
},
"scripts": {
"build-dev": "rollup -c --environment BUILD:dev && npm run demos-web",
"watch-dev": "rollup -c --environment BUILD:dev --watch",
"build": "webpack",
"build-lib": "babel src --out-dir lib",
"bundler": "electron ./bundler/app.js",

View File

@ -1,14 +1,18 @@
import fs from 'fs';
import sourcemaps from 'rollup-plugin-sourcemaps';
import { plugins } from './build/rollup_plugins';
// import sourcemaps from 'rollup-plugin-sourcemaps';
import buble from 'rollup-plugin-buble';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import { createFilter } from 'rollup-pluginutils';
import { terser } from 'rollup-plugin-terser';
const { BUILD, MINIFY } = process.env;
const minified = MINIFY === 'true';
const production = BUILD === 'production';
const outputFile = !production
? 'dist/l7-dev.js'
? 'build/L7.js'
: minified
? 'dist/l7.js'
: 'dist/l7-unminified.js';
? 'build/l7.js'
: 'build/l7-unminified.js';
const config = [
{
@ -22,12 +26,31 @@ const config = [
},
experimentalCodeSplitting: true,
treeshake: production,
plugins: plugins()
plugins: [
glsl(
[ './src/geom/shader/*.glsl', './src/core/engine/picking/*.glsl' ],
production
),
minified ? terser() : false,
buble({
transforms: { dangerousForOf: true },
objectAssign: 'Object.assign'
}),
resolve({
browser: true,
preferBuiltins: false
}),
commonjs({
// global keyword handling causes Webpack compatibility issues, so we disabled it:
// https://github.com/mapbox/mapbox-gl-js/pull/6956
ignoreGlobal: true
})
]
},
{
input: 'rollup/mapboxgl.js',
input: 'rollup/l7.js',
output: {
name: 'mapboxgl',
name: 'L7',
file: outputFile,
format: 'umd',
sourcemap: production ? true : 'inline',
@ -47,3 +70,28 @@ const config = [
];
export default config;
function glsl(include, minify) {
const filter = createFilter(include);
return {
name: 'glsl',
transform(code, id) {
if (!filter(id)) return;
// barebones GLSL minification
if (minify) {
code = code
.trim() // strip whitespace at the start/end
.replace(/\s*\/\/[^\n]*\n/g, '\n') // strip double-slash comments
.replace(/\n+/g, '\n') // collapse multi line breaks
.replace(/\n\s+/g, '\n') // strip identation
.replace(/\s?([+-\/*=,])\s?/g, '$1') // strip whitespace around operators
.replace(/([;\(\),\{\}])\n(?=[^#])/g, '$1'); // strip more line breaks
}
return {
code: `export default ${JSON.stringify(code)};`,
map: { mappings: '' }
};
}
};
}

19
rollup/bundle_prelude.js Normal file
View File

@ -0,0 +1,19 @@
/* eslint-disable */
var shared, worker, L7;
// define gets called three times: one for each chunk. we rely on the order
// they're imported to know which is which
function define(_, chunk) {
if (!shared) {
shared = chunk;
} else if (!worker) {
worker = chunk;
} else {
var workerBundleString = 'var sharedChunk = {}; (' + shared + ')(sharedChunk); (' + worker + ')(sharedChunk);'
var sharedChunk = {};
shared(sharedChunk);
L7 = chunk(sharedChunk);
L7.workerUrl = window.URL.createObjectURL(new Blob([workerBundleString], { type: 'text/javascript' }));
}
}

View File

@ -0,0 +1,4 @@
import './build/l7/shared';
import './build/l7/worker';
import './build/l7/index';
export default L7;

View File

@ -1,17 +1,9 @@
// import Util from './util';
import Scene from './core/scene';
import Global from './global';
const version = Global.version;
const track = function(enable) {
Global.trackable = enable;
};
import './track';
export {
const exported = {
version,
Scene,
track
Scene
};
export default exported;

View File

@ -42,33 +42,33 @@ export default class PointLayer extends Layer {
switch (pointShapeType) {
case 'fill' :// 填充图形
{
if (fill !== 'none') { // 是否填充
const attributes = PointBuffer.FillBuffer(this.layerData, style);
const meshfill = drawPoint.DrawFill(attributes, this.get('styleOptions'));
this.add(meshfill);
{
if (fill !== 'none') { // 是否填充
const attributes = PointBuffer.FillBuffer(this.layerData, style);
const meshfill = drawPoint.DrawFill(attributes, this.get('styleOptions'));
this.add(meshfill);
}
if (stroke !== 'none') { // 是否绘制边界
const lineAttribute = PointBuffer.StrokeBuffer(this.layerData, style);
const meshStroke = drawPoint.DrawStroke(lineAttribute, this.get('styleOptions'));
this.add(meshStroke, 'line');
}
break;
}
if (stroke !== 'none') { // 是否绘制边界
const lineAttribute = PointBuffer.StrokeBuffer(this.layerData, style);
const meshStroke = drawPoint.DrawStroke(lineAttribute, this.get('styleOptions'));
this.add(meshStroke, 'line');
}
break;
}
case 'image':// 绘制图片标注
{
const imageAttribute = PointBuffer.ImageBuffer(this.layerData, { imagePos: this.scene.image.imagePos });
const imageMesh = drawPoint.DrawImage(imageAttribute, { ...style, texture: this.scene.image.texture });
this.add(imageMesh);
break;
}
{
const imageAttribute = PointBuffer.ImageBuffer(this.layerData, { imagePos: this.scene.image.imagePos });
const imageMesh = drawPoint.DrawImage(imageAttribute, { ...style, texture: this.scene.image.texture });
this.add(imageMesh);
break;
}
case 'normal' : // 原生点
{
const normalAttribute = PointBuffer.NormalBuffer(this.layerData, style);
const normalPointMesh = drawPoint.DrawNormal(normalAttribute, style);
this.add(normalPointMesh);
break;
}
{
const normalAttribute = PointBuffer.NormalBuffer(this.layerData, style);
const normalPointMesh = drawPoint.DrawNormal(normalAttribute, style);
this.add(normalPointMesh);
break;
}
default:
return null;
}

View File

@ -21,7 +21,6 @@ export default function DrawAnimate(attributes, style) {
ANIMATE: true
});
const fillPolygonMesh = new THREE.Mesh(geometry, material);
this.fillPolygonMesh = fillPolygonMesh;
return fillPolygonMesh;
}

View File

@ -1,23 +1,4 @@
import Source from '../core//source';
this.addEventListener('message', e => {
const res = e.data;
// res = {
// command : 'POLYGON-EXTRUDE',
// data : {data:geojson,options:{}}
// }
let result;
switch (res.command) {
case 'geojson':
result = res;
self.postMessage(result);
break;
default:
self.postMessage(result);
break;
}
});
this.addEventListener('error', function(e) {
console.error(
'filename:' + e.filename + '\nmessage:' + e.message + '\nline:' + e.lineno
);
});
const a = 'webWorker Test';
export default Source;