diff --git a/demos/01_point_circle.html b/demos/01_point_circle.html index dd338d5e01..2b66ddd6a2 100644 --- a/demos/01_point_circle.html +++ b/demos/01_point_circle.html @@ -15,29 +15,6 @@
-
-

杭州市微博签到数据

-

- -

-

- -

-

-

-
@@ -58,7 +35,7 @@ const scene = new L7.Scene({ mapStyle: 'light', // 样式URL center: [ 120.19382669582967, 30.258134 ], pitch: 0, - zoom: 11.6 + zoom: 12 }); window.scene = scene; scene.on('loaded', () => { @@ -74,7 +51,7 @@ scene.on('loaded', () => { } }) .shape('2d:circle') - .size('value', [ 0, 60]) // default 1 + .size('value', [ 2, 80]) // default 1 //.size('value', [ 10, 300]) // default 1 .active(true) .filter('value', field_8 => { @@ -87,20 +64,7 @@ scene.on('loaded', () => { opacity: 0.9 }) .render(); - $('.info-panel input').change(function(){ - $(this).next().text($(this).val()); - const min = $('.info-panel input').val(); - const max = $($('.info-panel input')[1]).val(); - circleLayer.filter('value',(value)=>{ - return (value>=min && value<=max) - }).render(); - }) - $('.info-panel select').change(function(){ - const color = $(this).val(); - console.time('color'); - circleLayer.color('type',colorObj[color]).render(); - console.timeEnd('color') - }) + }); diff --git a/demos/01_point_column.html b/demos/01_point_column.html index cf83d33d2d..354c58a316 100644 --- a/demos/01_point_column.html +++ b/demos/01_point_column.html @@ -23,13 +23,13 @@ const scene = new L7.Scene({ id: 'map', mapStyle: 'dark', // 样式URL - center: [ 120.037828998113099, 30.086317611850635 ], - pitch: 36.002858, - zoom: 5.44 + center: [104.838088,34.075889 ], + pitch: 35, + zoom: 4.88, + rotation:4.183582 }); -window.scene = scene; scene.on('loaded', () => { - $.get('./data/rainfall.json', data => { + $.get('https://gw.alipayobjects.com/os/rmsportal/oVTMqfzuuRFKiDwhPSFL.json', data => { scene.PointLayer({ zIndex: 2 }) @@ -40,14 +40,13 @@ scene.on('loaded', () => { }) .shape('3d:circle') .size('t',(level)=> { - return [4,4,(level+40)]; + return [2,2,(level*3+20)]; }) .active(true) .color('t', ["#002466","#105CB3","#2894E0","#CFF6FF","#FFF5B8","#FFAB5C","#F27049","#730D1C"]) .render(); }); }); - diff --git a/demos/01_point_image.html b/demos/01_point_image.html index 6902b67f2d..96473b18c1 100644 --- a/demos/01_point_image.html +++ b/demos/01_point_image.html @@ -80,7 +80,7 @@ scene.on('loaded', () => { .size(8) .shape('2d:circle') .style({ - opacity:1.0 + opacity:0.7 }) .render(); diff --git a/demos/02_contour.html b/demos/02_contour.html index dd7bf8e677..b2782dde8c 100644 --- a/demos/02_contour.html +++ b/demos/02_contour.html @@ -25,9 +25,9 @@ const color1 = [ 'rgba(37, 140, 249, 0.8)', 'rgba(14, 241, 242, 0.8)', 'rgba(255 const scene = new L7.Scene({ id: 'map', mapStyle: 'dark', // 样式URL - center: [ 102.615023, 23.107799], + center: [ 102.602992, 23.107329], pitch: 15, - zoom: 14, + zoom: 14.82, }); scene.on('loaded', () => { $.get('./data/contour.geojson', data => { diff --git a/demos/02_oneBletoneRoad.html b/demos/02_oneBletoneRoad.html index aeec0e50b1..c7a5f17796 100644 --- a/demos/02_oneBletoneRoad.html +++ b/demos/02_oneBletoneRoad.html @@ -28,11 +28,10 @@ const scene = new L7.Scene({ }); scene.on('loaded', () => { -scene.image.addImage('marker', './data/onebelt/marker.png'); -scene.image.addImage('local', './image/local.png'); +scene.image.addImage('local', 'https://gw.alipayobjects.com/zos/rmsportal/xZXhTxbglnuTmZEwqQrE.png'); -$.getJSON('./data/onebelt/regions.json', region => { +$.getJSON('https://gw.alipayobjects.com/os/rmsportal/UpapMomPYUeiBjbHNAma.json', region => { const color = [ 'rgb(22,32,101)', 'rgb(28,43,127)', 'rgb(36,68,142)', 'rgb(45,94,158)', 'rgb(53,119,174)', 'rgb(61,145,190)', 'rgb(70,170,206)', 'rgb(98,190,210)', 'rgb(138,205,206)', 'rgb(179,221,204)', 'rgb(220,236,201)' ]; var points = region.features.map((feature)=>{ return feature.properties; @@ -48,7 +47,7 @@ $.getJSON('./data/onebelt/regions.json', region => { .shape('fill') .render(); }); -$.getJSON('./data/onebelt/seaway.geojson', contourData => { +$.getJSON('https://gw.alipayobjects.com/os/rmsportal/kwUdcXnxQtexeGRvTGtA.json', contourData => { const layer = scene.LineLayer({ zIndex:2} @@ -62,7 +61,7 @@ $.getJSON('./data/onebelt/seaway.geojson', contourData => { }) .render(); }); -$.getJSON('./data/onebelt/landway.json', contourData => { +$.getJSON('https://gw.alipayobjects.com/os/rmsportal/dzpMOiLYBKxpdmsgBLoE.json', contourData => { const landlayer = scene.LineLayer( {zIndex:2} ) @@ -75,7 +74,7 @@ $.getJSON('./data/onebelt/landway.json', contourData => { }) .render(); }); -$.getJSON('./data/onebelt/city.geojson', city => { +$.getJSON('https://gw.alipayobjects.com/os/rmsportal/opYqFyDGyGUAUXkLUhBV.json', city => { var makerLayer = scene.PointLayer({ zIndex: 4 }) diff --git a/demos/03_1_extrude_polygon.html b/demos/03_1_extrude_polygon.html index 86523e98a7..f8b80004ae 100644 --- a/demos/03_1_extrude_polygon.html +++ b/demos/03_1_extrude_polygon.html @@ -24,20 +24,22 @@ const scene = new L7.Scene({ id: 'map', mapStyle: 'dark', // 样式URL - center: [ 120.4047, 30.0679 ], - pitch: 35, - zoom: 4 + center: [104.838088,34.075889 ], + pitch: 27, + zoom: 4.5, + rotation:4.183582 }); window.scene = scene; scene.on('loaded', () => { - $.getJSON('./data/chinandvohexagon.geojson', city => { + $.getJSON('https://gw.alipayobjects.com/os/rmsportal/xxvoBnsYNEPiAXGRmlPD.json', city => { citylayer = scene.PolygonLayer() .source(city) .color('sum', ["#FAFFF0", "#EBF7D2", "#C8E695", "#A5D660", "#7DC238", "#59A616", "#3F8C0B", "#237804", "#125200", "#082B00"]) .shape('extrude') .size('max',(value)=>{ + if(value<0)value =0; return value * 1000; }) .active(true) diff --git a/demos/03_choropleths_polygon.html b/demos/03_choropleths_polygon.html index a405d8e933..a4dee381b4 100644 --- a/demos/03_choropleths_polygon.html +++ b/demos/03_choropleths_polygon.html @@ -36,9 +36,9 @@ const colorObj ={ const scene = new L7.Scene({ id: 'map', mapStyle: 'light', // 样式URL - center: [ 120.4047, 30.0679 ], + center: [104.838088,34.075889 ], pitch: 0, - zoom: 4 + zoom: 4.5, }); window.scene = scene; diff --git a/demos/04_image.html b/demos/04_image.html index 75ec505087..3f0773c96e 100644 --- a/demos/04_image.html +++ b/demos/04_image.html @@ -31,10 +31,8 @@ const scene = new L7.Scene({ }); scene.on('loaded', () => { -// https://gw.alipayobjects.com/zos/rmsportal/wAQqmdcWOPdomuKUyHDF.png -// const imageLayer = scene.ImageLayer(). - source('./image/hangzhoubay.jpg',{ + source('https://gw.alipayobjects.com/zos/rmsportal/FnHFeFklTzKDdUESRNDv.jpg',{ extent: [ 121.1680, 30.2828, 121.3840, 30.4219 ] }) diff --git a/demos/07_city.html b/demos/07_city.html index a08839ad21..70dd134c51 100644 --- a/demos/07_city.html +++ b/demos/07_city.html @@ -32,7 +32,7 @@ const scene = new L7.Scene({ }); window.scene = scene; scene.on('loaded', () => { - $.get('./data/water.geojson', data => { + $.get('https://gw.alipayobjects.com/os/rmsportal/XHMbjQwrSrajvLLvMPbK.json', data => { scene.PolygonLayer({ zIndex: 0 }) @@ -41,7 +41,7 @@ scene.on('loaded', () => { .color('rgb(79,174,234)') .render(); }); - $.get('./data/land.geojson', data => { + $.get('https://gw.alipayobjects.com/os/rmsportal/VifgwJEyBIXnDrjCwWdK.json', data => { scene.PolygonLayer({ zIndex: 0 }) @@ -50,7 +50,7 @@ scene.on('loaded', () => { .color('rgb(156,194,116)') .render(); }); - $.get('./data/river.geojson', data => { + $.get('https://gw.alipayobjects.com/os/rmsportal/ZseLNWMOPGrgqQYfvtli.json', data => { scene.LineLayer({ zIndex: 2 }) @@ -61,7 +61,7 @@ scene.on('loaded', () => { .render(); }); - $.get('./data/build.geojson', data => { + $.get('https://gw.alipayobjects.com/os/rmsportal/ggFwDClGjjvpSMBIrcEx.json', data => { citylayer = scene.PolygonLayer({ zIndex: 2 }) diff --git a/src/core/layer.js b/src/core/layer.js index f8132f46b0..a6b25b56bc 100644 --- a/src/core/layer.js +++ b/src/core/layer.js @@ -418,11 +418,6 @@ export default class Layer extends Base { }); } } - /** - * - * @param {*} overwrite - * @param {*} callback - */ on(type, callback) { this._addPickingEvents(); @@ -448,7 +443,7 @@ export default class Layer extends Base { const pickmaterial = new PickingMaterial({ u_zoom: this.scene.getZoom() }); - + const pickingMesh = new THREE[mesh.type](mesh.geometry, pickmaterial); pickmaterial.setDefinesvalue(this.type, true); pickingMesh.onBeforeRender = () => { @@ -464,7 +459,7 @@ export default class Layer extends Base { // TODO: Find a way to properly remove this listener on destroy this.scene.on('pick', e => { // Re-emit click event from the layer - const { featureId, point2d, point3d, intersects } = e; + const { featureId, point2d, intersects } = e; if (intersects.length === 0) { return; } const source = this.layerSource.get('data'); const feature = source.features[featureId]; @@ -493,7 +488,7 @@ export default class Layer extends Base { const colorAttr = this.layerMesh.geometry.attributes.a_color; const firstId = pickingId.indexOf(featureStyleId[0] + 1); for (let i = firstId; i < pickingId.length; i++) { - if (pickingId[i] == featureStyleId[0] + 1) { + if (pickingId[i] === featureStyleId[0] + 1) { colorAttr.array[i * 4 + 0] = color[0]; colorAttr.array[i * 4 + 1] = color[1]; colorAttr.array[i * 4 + 2] = color[2]; @@ -556,7 +551,7 @@ export default class Layer extends Base { } else if (this.type === 'polyline') { offset = 2; } - this._object3D.position.z = offset * Math.pow(2, 20 - zoom); + this._object3D.position.z = offset * Math.pow(2, 20 - zoom); if (zoom < minZoom || zoom > maxZoom) { this._object3D.visible = false; } else if (this.get('visible')) { @@ -569,11 +564,11 @@ export default class Layer extends Base { resetStyle() { const pickingId = this.layerMesh.geometry.attributes.pickingId.array; const colorAttr = this.layerMesh.geometry.attributes.a_color; - this._activeIds.forEach((index, value) => { + this._activeIds.forEach(index => { const color = this.StyleData[index].color; const firstId = pickingId.indexOf(index + 1); for (let i = firstId; i < pickingId.length; i++) { - if (pickingId[i] == index + 1) { + if (pickingId[i] === index + 1) { colorAttr.array[i * 4 + 0] = color[0]; colorAttr.array[i * 4 + 1] = color[1]; colorAttr.array[i * 4 + 2] = color[2]; diff --git a/src/core/scene.js b/src/core/scene.js index 52e9d90ed1..295c8d562a 100644 --- a/src/core/scene.js +++ b/src/core/scene.js @@ -35,6 +35,7 @@ export default class Scene extends Base { const sceneMap = new GaodeMap(Map.map); // eslint-disable-next-line Object.getOwnPropertyNames(sceneMap.__proto__).forEach((key)=>{ + // eslint-disable-next-line if ('key' !== 'constructor') { this.__proto__[key] = sceneMap.__proto__[key]; } }); this.map = Map.map; diff --git a/src/geom/buffer/point.js b/src/geom/buffer/point.js index bb928c86af..7de8e3536e 100644 --- a/src/geom/buffer/point.js +++ b/src/geom/buffer/point.js @@ -1,7 +1,6 @@ import BufferBase from './bufferBase'; import { regularShape } from '../shape/index'; import Util from '../../util'; -import * as THREE from '../../core/three'; export default class PointBuffer extends BufferBase { geometryBuffer() { const type = this.get('type'); diff --git a/src/geom/buffer/text.js b/src/geom/buffer/text.js index 1cab115a71..710dfd1bdc 100644 --- a/src/geom/buffer/text.js +++ b/src/geom/buffer/text.js @@ -1,5 +1,5 @@ import BufferBase from './bufferBase'; -import { getJSON, getImage } from '../../util/ajax'; +import { getJSON } from '../../util/ajax'; import * as THREE from '../../core/three'; import Global from '../../global'; const Space = 1; @@ -68,12 +68,17 @@ export default class TextBuffer extends BufferBase { }); } _loadTextTexture(url) { - getImage({ - url: `${Global.sdfHomeUrl}${url}` - }, (e, image) => { - this.bufferStruct.textTexture = this._creatTexture(image); + + + const img = new Image(); + img.crossOrigin = 'anonymous'; + + img.onload = () => { + this.bufferStruct.textTexture = this._creatTexture(img); this.emit('SourceLoaded'); - }); + }; + img.src = url; + } /** * 计算每个标注词语的位置 diff --git a/src/global.js b/src/global.js index 746aac3ca3..b537d8db38 100644 --- a/src/global.js +++ b/src/global.js @@ -22,7 +22,7 @@ const Global = { // 指定固定 tick 数的逼近值 snapCountArray: [ 0, 1, 1.2, 1.5, 1.6, 2, 2.2, 2.4, 2.5, 3, 4, 5, 6, 7.5, 8, 10 ], size: 10000, - sdfHomeUrl: 'http://visualtest.amap.com', + sdfHomeUrl: 'https://sdf.amap.com', scales: { } }; diff --git a/src/layer/pointLayer.js b/src/layer/pointLayer.js index 1ba952e088..f589eec221 100644 --- a/src/layer/pointLayer.js +++ b/src/layer/pointLayer.js @@ -7,7 +7,7 @@ import TextBuffer from '../geom/buffer/text'; import TextMaterial from '../geom/material/textMaterial'; import radar from '../geom/shader/radar_frag.glsl'; import warn from '../geom/shader/warn_frag.glsl'; -import pickingMaterial from '../core/engine/picking/pickingMaterial'; + /** * point shape 2d circle, traingle text,image @@ -58,7 +58,7 @@ export default class PointLayer extends Layer { // u_zoom: this.scene.getZoom() // }) // mtl.setDefinesvalue('point', true); - mtl.setDefinesvalue('SHAPE', true); + mtl.setDefinesvalue('SHAPE', true); if (shape === 'radar') { mtl.fragmentShader = radar; diff --git a/src/source/csvSource.js b/src/source/csvSource.js index 294407cc53..89dc55b1cc 100644 --- a/src/source/csvSource.js +++ b/src/source/csvSource.js @@ -21,8 +21,7 @@ export default class CSVSource extends Source { if (col.coordinates) { coordinates = col.coordinates; } - if(x && y) - coordinates = [ col[x], col[y] ]; + if (x && y) { coordinates = [ col[x], col[y] ]; } if (x1 && y1) { coordinates = [[ col[x], col[y] ], [ col[x1], col[y1] ]]; }