|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
import { HtmlRender, ICircle, IIcon, IIconOptions, ILayer, ILngLat, IMap, IMapOptions, IMarker, IMarkerCluster, IMarkOptions, IMouseTool, IInfoWindow, IPixel, IRenderClusterMarker, ISelf, ISize, PixelRender, ITileLayer, IDriving, IDrivingOptions, IAutocomplete, IPlaceSearch, AutocompleteSearchCallback, AutocompleteSelectCallback, PlaceSearchCallback } from './map' |
|
|
|
|
import { HtmlRender, ICircle, IIcon, IIconOptions, ILayer, ILngLat, IMap, IMapOptions, IMarker, IMarkerCluster, IMarkOptions, IMouseTool, IInfoWindow, IPixel, IRenderClusterMarker, ISelf, ISize, PixelRender, ITileLayer, IDriving, IDrivingOptions, IAutocomplete, IPlaceSearch, AutocompleteSearchCallback, AutocompleteSelectCallback, PlaceSearchCallback, AutocompleteSearch } from './map' |
|
|
|
|
import MapTools from './map-tools'; |
|
|
|
|
import * as global from 'globals'; |
|
|
|
|
import { SearchService } from '@src/app/searchComponent.service'; |
|
|
|
|
import { SearchDownList } from './component/SearchDownListPlugins/SearchDownList'; |
|
|
|
|
declare var AMap: any; |
|
|
|
|
declare var AMapUI: any; |
|
|
|
|
|
|
|
|
@ -376,20 +379,36 @@ export class GaodeDriving extends GaodeBasic implements IDriving {
|
|
|
|
|
|
|
|
|
|
export class GaodeAutocomplete extends GaodeBasic implements IAutocomplete { |
|
|
|
|
private component: any |
|
|
|
|
private searchDownList: SearchDownList |
|
|
|
|
constructor(options: any, component: any) { |
|
|
|
|
super(); |
|
|
|
|
this.component = component |
|
|
|
|
AMap.plugin('AMap.AutoComplete', () => { |
|
|
|
|
this.self = new AMap.Autocomplete(options) |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
this.searchDownList = global.injector.get<SearchService>(SearchService).appendComponentToBody(SearchDownList).instance; |
|
|
|
|
this.searchDownList.init(options.input); |
|
|
|
|
|
|
|
|
|
this.self.on('complete', (e) => { |
|
|
|
|
console.log('search complete', e); |
|
|
|
|
this.searchDownList.searchList = e.tips || []; |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
on(eventName: string, callback: AutocompleteSelectCallback) { |
|
|
|
|
return this.self.on(eventName, (event)=>{ |
|
|
|
|
callback.call(this.component,event) |
|
|
|
|
}) |
|
|
|
|
this.searchDownList.setClickHander(e => { |
|
|
|
|
alert(e.name); |
|
|
|
|
callback(e); |
|
|
|
|
}); |
|
|
|
|
//$().addEventListener
|
|
|
|
|
// return this.self.on(eventName, (event) => {
|
|
|
|
|
// console.log('on event', event)
|
|
|
|
|
// callback.call(this.component, event)
|
|
|
|
|
// })
|
|
|
|
|
} |
|
|
|
|
search(address: string, callback: AutocompleteSearchCallback) { |
|
|
|
|
return this.self.search(address,(status,result)=>{ |
|
|
|
|
return this.self.search(address, (status, result: AutocompleteSearch) => { |
|
|
|
|
this.searchDownList.searchList = result.tips || []; |
|
|
|
|
callback.call(this.component, status, result) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|