Browse Source

临时修改

上海一张图
陈鹏飞 4 years ago
parent
commit
f25b1565db
  1. 6
      src/app/app.component.ts
  2. 9
      src/app/pages/login/login.component.ts
  3. 5
      src/global.d.ts
  4. 1
      src/modules/map/declare/component/SearchDownListPlugins/SearchDownList.html
  5. 18
      src/modules/map/declare/component/SearchDownListPlugins/SearchDownList.ts
  6. 13
      src/modules/map/declare/keda-map.ts

6
src/app/app.component.ts

@ -1,4 +1,4 @@
import { Component } from '@angular/core'; import { Component, Inject, Injector } from '@angular/core';
import { HttpClient } from '@angular/common/http' import { HttpClient } from '@angular/common/http'
import { Data } from './interface' import { Data } from './interface'
import { Router,ActivatedRoute } from '@angular/router' import { Router,ActivatedRoute } from '@angular/router'
@ -14,7 +14,9 @@ import { MaskLayerService } from './mask-layer.service';
}) })
export class AppComponent { export class AppComponent {
constructor(private maskLayerService:MaskLayerService,private http:HttpClient,private router:Router,public token:CacheTokenService) { } constructor(private maskLayerService:MaskLayerService,private http:HttpClient,private router:Router,public token:CacheTokenService,private injector:Injector) {
window.injector = injector;
}
isMaskLayerShow:boolean = false isMaskLayerShow:boolean = false

9
src/app/pages/login/login.component.ts

@ -1,10 +1,12 @@
import { Component, OnInit } from '@angular/core'; import { ApplicationRef, Component, ComponentFactoryResolver, Injector, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http' import { HttpClient } from '@angular/common/http'
import { Data } from '../../interface' import { Data } from '../../interface'
import { Router,ActivatedRoute } from '@angular/router' import { Router,ActivatedRoute } from '@angular/router'
import {CacheTokenService} from '../../http-interceptors/cache-token.service'//引入服务 import {CacheTokenService} from '../../http-interceptors/cache-token.service'//引入服务
import { MatSnackBar,MatSnackBarConfig } from '@angular/material/snack-bar'; import { MatSnackBar,MatSnackBarConfig } from '@angular/material/snack-bar';
import { MatDialog,MatDialogRef } from '@angular/material/dialog'; import { MatDialog,MatDialogRef } from '@angular/material/dialog';
import { SearchService } from '@src/app/searchComponent.service';
import { SearchDownList } from '@src/modules/map/declare/component/SearchDownListPlugins/SearchDownList';
@ -15,7 +17,10 @@ import { MatDialog,MatDialogRef } from '@angular/material/dialog';
}) })
export class LoginComponent implements OnInit { export class LoginComponent implements OnInit {
constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public snackBar: MatSnackBar, public dialog: MatDialog) { } constructor(private http:HttpClient,private router:Router,private route:ActivatedRoute,public token:CacheTokenService,public snackBar: MatSnackBar, public dialog: MatDialog) {
window.injector.get<SearchService>(SearchService).appendComponentToBody(SearchDownList);
}
ngOnInit() { ngOnInit() {
this.automaticLogin() this.automaticLogin()

5
src/global.d.ts vendored

@ -0,0 +1,5 @@
import { Injector } from "@angular/core";
export declare interface Window {
injector: Injector
}

1
src/modules/map/declare/component/SearchDownListPlugins/SearchDownList.html

@ -1,3 +1,4 @@
<div class="content" [ngStyle]="{'left': leftCss,'top': topCss,'min-width': minWidthCss}" *ngIf="searchList.length"> <div class="content" [ngStyle]="{'left': leftCss,'top': topCss,'min-width': minWidthCss}" *ngIf="searchList.length">
<h1>I'm loaded</h1>
<div *ngFor="let item of searchList" (click)="select(item)" class="item">{{item.name}}</div> <div *ngFor="let item of searchList" (click)="select(item)" class="item">{{item.name}}</div>
</div> </div>

18
src/modules/map/declare/component/SearchDownListPlugins/SearchDownList.ts

@ -2,6 +2,8 @@ import { Component, OnInit, Inject } from '@angular/core';
import { AutocompleteSelect } from '../../map'; import { AutocompleteSelect } from '../../map';
type ClickHandler = (data:AutocompleteSelect)=>void;
@Component({ @Component({
selector: 'SearchDownList', selector: 'SearchDownList',
templateUrl: './SearchDownList.html', templateUrl: './SearchDownList.html',
@ -9,28 +11,32 @@ import { AutocompleteSelect } from '../../map';
}) })
export class SearchDownList implements OnInit { export class SearchDownList implements OnInit {
private $input; private $input;
constructor(inputListenId: string) { constructor() {
this.$input = document.getElementById(inputListenId);
} }
public searchList: AutocompleteSelect[] = []; //list public searchList: AutocompleteSelect[] = []; //list
public leftCss: string = '0px'; public leftCss: string = '0px';
public topCss: string = '0px'; public topCss: string = '0px';
public minWidthCss: string = '0px'; public minWidthCss: string = '0px';
private clickHandler:ClickHandler;
ngOnInit(): void { ngOnInit(): void {
} }
init(elementId:string,clickCallback:ClickHandler):void{
this.$input = document.getElementById(elementId);
this.clickHandler = clickCallback;
//this.addDOMEvent();
}
// input 添加监听事件 // input 添加监听事件
addDOMEvent() { addDOMEvent() {
let input = document.getElementById(id)
let DOM = input.getBoundingClientRect()
// this.left = DOM.left // this.left = DOM.left
// this.top = DOM.top + DOM.height + 2 // this.top = DOM.top + DOM.height + 2
// this.minWidth = DOM.width // this.minWidth = DOM.width
} }
select(e) { select(e) {
console.log(e) this.clickHandler(e);
this.searchList = [];
} }
watch() { watch() {

13
src/modules/map/declare/keda-map.ts

@ -1,5 +1,8 @@
import { AutocompleteSearchCallback, AutocompleteSelectCallback, HtmlRender, IAutocomplete, ICircle, IDriving, IInfoWindow, ILayer, ILngLat, IMap, IMapOptions, IMarker, IMarkerCluster, IMarkOptions, IMouseTool, IPixel, IPlaceSearch, IRenderClusterMarker, ISelf, ITileLayer, PixelRender, PlaceSearchCallback } from './map' import { AutocompleteSearchCallback, AutocompleteSelectCallback, HtmlRender, IAutocomplete, ICircle, IDriving, IInfoWindow, ILayer, ILngLat, IMap, IMapOptions, IMarker, IMarkerCluster, IMarkOptions, IMouseTool, IPixel, IPlaceSearch, IRenderClusterMarker, ISelf, ITileLayer, PixelRender, PlaceSearchCallback } from './map'
import * as ObjectID from 'bson-objectid'; import * as ObjectID from 'bson-objectid';
import { SearchDownList } from './component/SearchDownListPlugins/SearchDownList';
import { ApplicationRef, ComponentFactoryResolver, Injector, ReflectiveInjector } from '@angular/core';
import { SearchService } from '@src/app/searchComponent.service';
declare var KMap: any; declare var KMap: any;
class KedaBasic implements ISelf { class KedaBasic implements ISelf {
@ -314,12 +317,20 @@ export class KedaAutocomplete extends KedaBasic implements IAutocomplete { //Aut
constructor(options: any, component: any) { constructor(options: any, component: any) {
super(); super();
this.component = component this.component = component
const injector = Injector.create({
providers:
[{provide: SearchService, deps: [ComponentFactoryResolver,ApplicationRef,Injector]}]
});
injector.get<SearchService>(SearchService).appendComponentToBody(SearchDownList);
if (options && options.input != undefined) { //绑定input框搜索事件 if (options && options.input != undefined) { //绑定input框搜索事件
//KedaSearchComponent.instance.addDOMEvent(options.input) this.inputListen(options.input);
} }
} }
on(eventName: string, callback: AutocompleteSelectCallback) { on(eventName: string, callback: AutocompleteSelectCallback) {
}
inputListen(elementId:string){
} }
search(address: string, callback: AutocompleteSearchCallback) { search(address: string, callback: AutocompleteSearchCallback) {
(this.component.map as KeDaMap).self.queryInfoByType({ (this.component.map as KeDaMap).self.queryInfoByType({

Loading…
Cancel
Save