shengzheng1981 / green-gis-js Goto Github PK
View Code? Open in Web Editor NEWGreen GIS JS API is a lite GIS JS API based on Canvas API
License: MIT License
Green GIS JS API is a lite GIS JS API based on Canvas API
License: MIT License
measurer已经修复,editor比较复杂,目前没有思路。
map.ts
_onClick(event) { const matrix = (this._ctx as any).getTransform(); const x = (event.offsetX - matrix.e) / matrix.a; const y = (event.offsetY - matrix.f) / matrix.d; [event.lng, event.lat] = this._projection.unproject([x, y]); [event.originalLng, event.originalLat] = this._projection.unproject([x, y], true); if (this._editor && this._editor.editing) { this._editor._onClick(event); return; } if (this._measurer && this._measurer.measuring) { this._measurer._onClick(event); return; } //this._handlers["click"].forEach(handler => handler(event)); this.emit("click", event); }
_onMouseMove(event) { if (this._editor.editing) { const matrix = (this._ctx as any).getTransform(); const x = (event.offsetX - matrix.e) / matrix.a; const y = (event.offsetY - matrix.f) / matrix.d; [event.lng, event.lat] = this._projection.unproject([x, y]); [event.originalLng, event.originalLat] = this._projection.unproject([x, y], true); this._editor._onMouseMove(event); return; } if (this._measurer.measuring) { const matrix = (this._ctx as any).getTransform(); const x = (event.offsetX - matrix.e) / matrix.a; const y = (event.offsetY - matrix.f) / matrix.d; [event.lng, event.lat] = this._projection.unproject([x, y]); [event.originalLng, event.originalLat] = this._projection.unproject([x, y], true); this._measurer._onMouseMove(event); return; } if (!this._drag.flag) { this._handlers["mousemove"].forEach(handler => handler(event)); } }
measurer.ts
_onClick(event) { if (!this._measuring) return; if (event.detail > 1) return; if (this._action === MeasureActionType.Polygon) { if (this._create.click == 0) { this._createLayer.clear(); const point = new Point(event.originalLng, event.originalLat); const graphic = new Graphic(point, this._defaultPointSymbol); this._createLayer.add(graphic); this._create.click += 1; this._create.lnglats.push([event.originalLng, event.originalLat]); } else if (this._create.click == 1) { const second = new Point(event.originalLng, event.originalLat); const graphic1 = new Graphic(second, this._defaultPointSymbol); this._createLayer.add(graphic1); if (this._create.graphic) this._createLayer.remove(this._create.graphic); this._create.lnglats.push([event.originalLng, event.originalLat]); const line = new Polyline(this._create.lnglats); this._create.graphic = new Graphic(line, this._defaultLineSymbol); this._createLayer.add(this._create.graphic); this._create.click += 1; } else { const second = new Point(event.originalLng, event.originalLat); const graphic1 = new Graphic(second, this._defaultPointSymbol); this._createLayer.add(graphic1); if (this._create.graphic) this._createLayer.remove(this._create.graphic); this._create.lnglats.push([event.originalLng, event.originalLat]); const polygon = new Polygon([this._create.lnglats]); this._create.graphic = new Graphic(polygon, this._defaultPolygonSymbol); this._createLayer.add(this._create.graphic); this._create.click += 1; } } else if (this._action === MeasureActionType.Polyline) { if (this._create.click == 0) { this._createLayer.clear(); const point = new Point(event.originalLng, event.originalLat); const graphic = new Graphic(point, this._defaultPointSymbol); this._createLayer.add(graphic); this._create.click += 1; this._create.lnglats.push([event.originalLng, event.originalLat]); } else { const second = new Point(event.originalLng, event.originalLat); const graphic1 = new Graphic(second, this._defaultPointSymbol); this._createLayer.add(graphic1); if (this._create.graphic) this._createLayer.remove(this._create.graphic); this._create.lnglats.push([event.originalLng, event.originalLat]); const line = new Polyline(this._create.lnglats); this._create.graphic = new Graphic(line, this._defaultLineSymbol); this._createLayer.add(this._create.graphic); this._create.click += 1; } } }
_onMouseMove(event) { if (!this._measuring) return; if (this._action === MeasureActionType.Polygon) { if (this._create.click == 1) { if (this._create.graphic) this._createLayer.remove(this._create.graphic); const lnglats: any = [...this._create.lnglats]; lnglats.push([event.originalLng, event.originalLat]); const line = new Polyline(lnglats); this._create.graphic = new Graphic(line, this._defaultLineSymbol); this._createLayer.add(this._create.graphic); } else if (this._create.click > 1){ if (this._create.graphic) this._createLayer.remove(this._create.graphic); const lnglats: any = [...this._create.lnglats]; lnglats.push([event.originalLng, event.originalLat]); const polygon = new Polygon([lnglats]); this._create.graphic = new Graphic(polygon, this._defaultPolygonSymbol); this._createLayer.add(this._create.graphic); } } else if (this._action === MeasureActionType.Polyline) { if (this._create.click > 0) { if (this._create.graphic) this._createLayer.remove(this._create.graphic); const lnglats: any = [...this._create.lnglats]; lnglats.push([event.originalLng, event.originalLat]); const line = new Polyline(lnglats); this._create.graphic = new Graphic(line, this._defaultLineSymbol); this._createLayer.add(this._create.graphic); } } this.redraw(); }
multiple-polygon.ts 中多面的数据结构发生变化,导致获取的中心点[NAN,NAN]
The lesson is very nice and i leanred much. But now i have a problem, how to reproject a raster image from wgs84 to web mercator in js? I konw how to transform a point coordinate, but I have no idea of how to operate image. Could you give me some ideas please? Best wishes to you!
fitBound方法通过unproject得到的中心点坐标是偏移后的坐标,setView方法传入偏移后的坐标会再偏移一次。
1、是否考虑将GraphicLayer和SelectionLayer相关的方法放到viewer中
2、GraphicLayer和SelectionLayer remove或者clear后调用draw方法不会生效,需要重绘视图
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.