From 769d84e98ce50ed168d26d2f6b82177b9c786685 Mon Sep 17 00:00:00 2001 From: fengxiang <110431245@qq.com> Date: Tue, 14 Aug 2018 13:26:45 +0800 Subject: [PATCH] 菜单更新 --- src/app/routes/grid-trace/grid-trace.component.ts | 121 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 116 insertions(+), 5 deletions(-) diff --git a/src/app/routes/grid-trace/grid-trace.component.ts b/src/app/routes/grid-trace/grid-trace.component.ts index 10972ac..1bff5e6 100644 --- a/src/app/routes/grid-trace/grid-trace.component.ts +++ b/src/app/routes/grid-trace/grid-trace.component.ts @@ -1,17 +1,128 @@ import { Component, OnInit } from '@angular/core'; import { _HttpClient } from '@delon/theme'; +import { MapOptions, HeatmapData, HeatmapOptions, NavigationControlOptions, ControlAnchor, NavigationControlType } from 'angular2-baidu-map'; @Component({ selector: 'app-grid-trace', templateUrl: './grid-trace.component.html', }) export class GridTraceComponent implements OnInit { - + options: MapOptions; + private _map: any; constructor( private http: _HttpClient - ) { } - - ngOnInit() { + ) { + this.options = { + minZoom: 3, + maxZoom: 20, + cursor: 'default', + centerAndZoom: { + lng: 121, + lat: 31.4, + zoom: 15 + }, + enableKeyboard: true + }; } - + loadMap(map: any) { + this._map = map; + this.showGrid(); + this._map.addEventListener( + 'tilesloaded', () => { + this.showGrid(); + } + ) + } + navigationOpts: NavigationControlOptions; + //��������� + heatData: HeatmapData = { + data: [ + {"lng":121,"lat":31.4,"count":99}, + {"lng":120.99,"lat":31.399,"count":95}, + {"lng":121.002,"lat":31.392,"count":80}, + ], + max: 100 + }; + heatOption: HeatmapOptions = { + radius: 100 + }; + heatmapOverlay :any; + /** + * loadHeatmap + */ + public loadHeatmap(heatmapOverlay) { + this.heatmapOverlay = heatmapOverlay; + } + ngOnInit() { + this.navigationOpts = { + anchor: ControlAnchor.BMAP_ANCHOR_BOTTOM_RIGHT, + type: NavigationControlType.BMAP_NAVIGATION_CONTROL_LARGE + }; + } + //map��������������� + // TODO ������ + bs() { + debugger; + var bs = this._map.getBounds(); //������������������������������������ + // var bssw = bs.getSouthWest(); //���������������������������(������������) + // var bsne = bs.getNorthEast(); //���������������������������(������������) + if(!this.topLeftAnchor){ + this.topLeftAnchor = {x0:0,y0:0}; + this.topLeftAnchor.x0 = bs.Ol.lng; + this.topLeftAnchor.y0 = bs.xl.lat; + } + return { 'x1': bs.Ol.lng, 'y1': bs.Ol.lat, 'x2': bs.xl.lng, 'y2': bs.xl.lat }; + } + private topLeftAnchor = null; + /** + * ������������ + */ + // TODO ������ + private showGridPolygons = []; + showGrid(){ + if(this._map.getZoom()<14){ + return; + } + const XY = this.bs(); + var X1 = XY.x1; + var Y2 = XY.y2; + var X0 = this.topLeftAnchor.x0; + var Y0 = this.topLeftAnchor.y0; + var width = 0.0063; + var height = 0.0048; + // var multiple = 1000000; + if(!!this.topLeftAnchor) { + X1=X0 + Math.ceil((X1-X0)/width-1)*width; + Y2=Y0 + Math.ceil((Y2-Y0)/height)*height; + } + let polygons = []; + for (let i = X1; i < XY.x2; i = i + width) { + for (let j = Y2; j > XY.y1; j = j - height) { + //���������������������������������������������������:������������������Point���������������������������,���������������������������,���������������������������,���������������������������������������������������������������������������������������������������������������,������������������������������������������������������������������ + const polygon = new window.BMap.Polygon([ + new window.BMap.Point(i, j), //������������������ + new window.BMap.Point(i, j-height), //������������������ + new window.BMap.Point(i+width, j-height), //������������������ + new window.BMap.Point(i+width, j) //������������������ + ], {strokeColor:"blue", strokeWeight:2, strokeOpacity:0.5, fillOpacity:0.1}); + // polygon .addEventListener("click",function clickFunction(){ + // alert("������������������"); + // }); + // _map.addOverlay(polygon); + polygons.push(polygon); + } + } + if(!!this.showGridPolygons && this.showGridPolygons.length > 0){ + this.showGridPolygons.forEach( + polygon => { + this._map.removeOverlay(polygon); + } + ); + } + // this._map.addOverlays(polygons); + polygons.forEach(polygon=>{ + this._map.addOverlay(polygon); + }); + this.showGridPolygons = polygons; + } } -- Gitblit v1.8.0