|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import { AutocompleteSearchCallback, AutocompleteSelectCallback, ClickOptions, DrivingSearchCallback, EventCallback, HtmlRender, IAutocomplete, ICircle, IDriving, IInfoWindow, ILayer, ILngLat, IMap, IMapOptions, IMarker, IMarkerCluster, IMarkOptions, IMouseTool, IPixel, IPlaceSearch, IRenderClusterMarker, ISelf, ITileLayer, MarkerClusterCallback, PixelRender, PlaceSearchCallback } from './map' |
|
|
|
|
import { AutocompleteSearch, AutocompleteSearchCallback, AutocompleteSelect, AutocompleteSelectCallback, ClickOptions, DrivingSearchCallback, EventCallback, HtmlRender, IAutocomplete, ICircle, IDriving, IInfoWindow, ILayer, ILngLat, IMap, IMapOptions, IMarker, IMarkerCluster, IMarkOptions, IMouseTool, IPixel, IPlaceSearch, IRenderClusterMarker, ISelf, ITileLayer, MarkerClusterCallback, PixelRender, PlaceSearchCallback } from './map' |
|
|
|
|
import { SearchDownList } from './component/SearchDownListPlugins/SearchDownList'; |
|
|
|
|
import { SearchService } from '@src/app/searchComponent.service'; |
|
|
|
|
import { HttpClient } from '@angular/common/http'; |
|
|
|
|
import * as ObjectID from 'bson-objectid'; |
|
|
|
|
import * as global from 'globals'; |
|
|
|
|
declare var KMap: any; |
|
|
|
@ -14,6 +15,8 @@ const beforCity: string = "上海市"; //当前城市
|
|
|
|
|
const cityCode: string = "310000"; //当前城市 行政编码
|
|
|
|
|
|
|
|
|
|
export class KeDaMap extends KedaBasic implements IMap { |
|
|
|
|
public isLoadEnd:boolean = false |
|
|
|
|
public LoadedCallback:Function[] = []; |
|
|
|
|
constructor(container: string, options: IMapOptions) { //地图初始化
|
|
|
|
|
super(); |
|
|
|
|
let that = this |
|
|
|
@ -22,6 +25,9 @@ export class KeDaMap extends KedaBasic implements IMap {
|
|
|
|
|
opt.targetCoordinateType = "WGS84"; |
|
|
|
|
opt.center = cityPosition; |
|
|
|
|
opt.zoom === undefined ? opt.zoom = 9 : opt.zoom = opt.zoom - 2 |
|
|
|
|
if (opt.mapStyle && opt.mapStyle == 'amap://styles/grey') { |
|
|
|
|
opt.solution = '8888' |
|
|
|
|
} |
|
|
|
|
let mapLayer = function () { |
|
|
|
|
if (opt.viewMode && opt.viewMode == "3D") { |
|
|
|
|
let data = { |
|
|
|
@ -39,6 +45,15 @@ export class KeDaMap extends KedaBasic implements IMap {
|
|
|
|
|
}; |
|
|
|
|
that.self.add3DLayer({ data: data }); |
|
|
|
|
} |
|
|
|
|
that.isLoadEnd = true |
|
|
|
|
that.LoadedCallback.forEach(i=>{ |
|
|
|
|
try{ |
|
|
|
|
i(); |
|
|
|
|
}catch(e) { |
|
|
|
|
console.log(e,'错误') |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
that.LoadedCallback = [] |
|
|
|
|
} |
|
|
|
|
opt.onLoadMap = mapLayer |
|
|
|
|
this.self = new KMap(opt); |
|
|
|
@ -54,33 +69,42 @@ export class KeDaMap extends KedaBasic implements IMap {
|
|
|
|
|
return d; |
|
|
|
|
} |
|
|
|
|
setAdministrativeAreaStyle(component: any, getData?: Function, setData?: Function) { //自定义 行政区划 样式
|
|
|
|
|
let beforeCode = cityCode //当前 城市行政编码
|
|
|
|
|
let _this =this; |
|
|
|
|
if(!this.isLoadEnd){ |
|
|
|
|
this.LoadedCallback.push( |
|
|
|
|
()=>_this.setAdministrativeAreaStyle(component,getData,setData)
|
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
let beforeCode:string = cityCode //当前 城市行政编码
|
|
|
|
|
let setTime //延时器
|
|
|
|
|
let initMap = ()=>{ //绘制地图
|
|
|
|
|
this.self.getGeometryByAdminCode({ |
|
|
|
|
code: beforeCode, |
|
|
|
|
callback: function (res) { |
|
|
|
|
callback: (res)=> { |
|
|
|
|
this.self.highlightPolygon({ |
|
|
|
|
color: 'rgba(255,0,0,0.5)', |
|
|
|
|
area:res.data |
|
|
|
|
color: 'rgba(0,102,255,0.5)', |
|
|
|
|
area: res.data |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} //function
|
|
|
|
|
let clickMap = (e)=>{ //点击地图
|
|
|
|
|
console.log(e,'点击map') |
|
|
|
|
this.self.getAdminInfoByPoint({ |
|
|
|
|
point: e.position, |
|
|
|
|
_this.self.getAdminInfoByPoint({ |
|
|
|
|
point: [e.lnglat.lng, e.lnglat.lat], |
|
|
|
|
callback: (res)=>{ |
|
|
|
|
if (res.status === 10) { |
|
|
|
|
if (res.data.adminId != beforeCode && res.data.parentId === cityCode) { //当前点击位置已改动
|
|
|
|
|
console.log(res.data,'当前点击行政区域') |
|
|
|
|
if (res.data.adminId != beforeCode && res.data.parentId == cityCode) { //当前点击位置已改动
|
|
|
|
|
_this.self.clear() |
|
|
|
|
window.clearTimeout(setTime) |
|
|
|
|
beforeCode = res.data.adminId |
|
|
|
|
beforeCode = (res.data.adminId).toString() |
|
|
|
|
setTime = window.setTimeout(()=>{ initMap() },100) |
|
|
|
|
let name = { properties:{name: res.data.cityName } } |
|
|
|
|
let name = { properties:{name: res.data.nameZh } } |
|
|
|
|
getData && getData.call(component,name); |
|
|
|
|
return |
|
|
|
|
} else if (res.data.adminId != beforeCode || res.data.parentId != cityCode) { |
|
|
|
|
} else if (res.data.parentId != cityCode) { |
|
|
|
|
_this.self.clear() |
|
|
|
|
window.clearTimeout(setTime) |
|
|
|
|
beforeCode = cityCode |
|
|
|
|
setTime = window.setTimeout(()=>{ initMap() },100) |
|
|
|
@ -88,6 +112,7 @@ export class KeDaMap extends KedaBasic implements IMap {
|
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if (beforeCode != cityCode) { |
|
|
|
|
_this.self.clear() |
|
|
|
|
window.clearTimeout(setTime) |
|
|
|
|
beforeCode = cityCode |
|
|
|
|
setTime = window.setTimeout(()=>{ initMap() },100) |
|
|
|
@ -97,19 +122,11 @@ export class KeDaMap extends KedaBasic implements IMap {
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
this.self.addEventOnMap({ |
|
|
|
|
event: "load", |
|
|
|
|
handler: ()=>{ |
|
|
|
|
initMap() |
|
|
|
|
let level = Number(sessionStorage.getItem("level")) |
|
|
|
|
if (level < 3) { |
|
|
|
|
this.self.addEventOnMap({ |
|
|
|
|
event: "click", |
|
|
|
|
handler: clickMap |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
initMap() |
|
|
|
|
let level = Number(sessionStorage.getItem("level")) |
|
|
|
|
if (level < 3) { |
|
|
|
|
this.on("click",clickMap,this); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
clearMap() { |
|
|
|
|
this.self.clear() |
|
|
|
@ -131,20 +148,30 @@ export class KeDaMap extends KedaBasic implements IMap {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
getBounds() { |
|
|
|
|
let bounds |
|
|
|
|
let bounds = { |
|
|
|
|
northEast: null, |
|
|
|
|
southWest: null |
|
|
|
|
} |
|
|
|
|
this.self.getBounds({ |
|
|
|
|
callback: (res) => { |
|
|
|
|
bounds = res.data |
|
|
|
|
console.log(res.data) |
|
|
|
|
bounds.northEast = new KeDaLngLat(res.data[0][0],res.data[0][1]) |
|
|
|
|
bounds.southWest = new KeDaLngLat(res.data[1][0],res.data[1][1]) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
return bounds |
|
|
|
|
} |
|
|
|
|
add(obj: any) { |
|
|
|
|
let _this =this; |
|
|
|
|
if(!this.isLoadEnd){ |
|
|
|
|
this.LoadedCallback.push( |
|
|
|
|
()=>_this.add(obj)
|
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
if (obj && obj.typeName === "KeDaMarker") { |
|
|
|
|
let _marker = (obj as KeDaMarker); |
|
|
|
|
_marker.map = this; |
|
|
|
|
this.self.addMarkers(_marker.self) |
|
|
|
|
this.self.addCustomOverlay(_marker.self) |
|
|
|
|
} else if (obj == "卫星图层") { |
|
|
|
|
this.self.setImageLayer({ display: true }) |
|
|
|
|
} else if (obj == "路网图层") { |
|
|
|
@ -153,11 +180,11 @@ export class KeDaMap extends KedaBasic implements IMap {
|
|
|
|
|
} |
|
|
|
|
remove(obj: any) { |
|
|
|
|
if (obj && obj.typeName === "KeDaMarker") { |
|
|
|
|
this.self.removeMarkersByType({ markerType: obj.id }) |
|
|
|
|
obj.KedaMarkerID && this.self.removeCustomOverlayById({ id: obj.KedaMarkerID }) |
|
|
|
|
} else if (obj && obj.typeName === "KeDaInfoWindow") { |
|
|
|
|
this.self.removeAllPopups() |
|
|
|
|
} else if (obj && obj.typeName === "KeDaCircle") { |
|
|
|
|
this.self.removeLayer({ layerId: obj.id }) |
|
|
|
|
obj.id && this.self.removeLayer({ layerId: obj.id }) |
|
|
|
|
} else if (obj == "卫星图层") { |
|
|
|
|
this.self.setImageLayer({ display: false }) |
|
|
|
|
} else if (obj == "路网图层") { |
|
|
|
@ -166,7 +193,7 @@ export class KeDaMap extends KedaBasic implements IMap {
|
|
|
|
|
} |
|
|
|
|
setCity(city: string) { |
|
|
|
|
let that = this |
|
|
|
|
if (city.includes("上海") && this.self.flyTo instanceof Function) { |
|
|
|
|
if (city.includes("上海") && this.isLoadEnd) { |
|
|
|
|
that.self.flyTo({ |
|
|
|
|
zoom: 9, |
|
|
|
|
point: cityPosition |
|
|
|
@ -174,7 +201,8 @@ export class KeDaMap extends KedaBasic implements IMap {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
getCity(callback: Function) { |
|
|
|
|
return callback |
|
|
|
|
let autoOptions = { city: "上海" } |
|
|
|
|
return callback(autoOptions) |
|
|
|
|
} |
|
|
|
|
setZoom(zoom: number) { |
|
|
|
|
this.self.zoomTo({ |
|
|
|
@ -191,6 +219,13 @@ export class KeDaMap extends KedaBasic implements IMap {
|
|
|
|
|
return num |
|
|
|
|
} |
|
|
|
|
setCenter(pos: number[] | ILngLat) { |
|
|
|
|
let _this =this; |
|
|
|
|
if(!this.isLoadEnd){ |
|
|
|
|
this.LoadedCallback.push( |
|
|
|
|
()=>_this.setCenter(pos)
|
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
let position = [] |
|
|
|
|
if (pos instanceof Array) { |
|
|
|
|
position = pos |
|
|
|
@ -204,12 +239,18 @@ export class KeDaMap extends KedaBasic implements IMap {
|
|
|
|
|
this.self.getCenter({ |
|
|
|
|
callback: function (res) { |
|
|
|
|
center = res.data |
|
|
|
|
console.log(res); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
return center |
|
|
|
|
} |
|
|
|
|
on(eventName: string, callback: EventCallback, component?: any) { |
|
|
|
|
let _this =this; |
|
|
|
|
if(!this.isLoadEnd){ |
|
|
|
|
this.LoadedCallback.push( |
|
|
|
|
()=>_this.on(eventName,callback,component)
|
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
let eventMapProfile = { |
|
|
|
|
complete: "load", |
|
|
|
|
click: "click", |
|
|
|
@ -218,11 +259,17 @@ export class KeDaMap extends KedaBasic implements IMap {
|
|
|
|
|
if (eventName == "click") { |
|
|
|
|
this.self.addEventOnMap({event: "click", |
|
|
|
|
handler: (res)=>{ |
|
|
|
|
console.log(res,'地图点击') |
|
|
|
|
var d:ClickOptions = res.data.map(); |
|
|
|
|
callback.call(component,d); |
|
|
|
|
let event = { |
|
|
|
|
lnglat: new KeDaLngLat(res.lngLat.lng,res.lngLat.lat), |
|
|
|
|
pixel: new KeDaPixel(res.point.x,res.point.y), |
|
|
|
|
type: res.type, |
|
|
|
|
target: { id:null } //TODO
|
|
|
|
|
} |
|
|
|
|
callback.call(component,event); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else if (eventName == "complete") { |
|
|
|
|
callback.call(component,null); |
|
|
|
|
} else { |
|
|
|
|
this.self.addEventOnMap({ |
|
|
|
|
event: eventMapProfile[eventName], |
|
|
|
@ -248,7 +295,9 @@ export class KeDaPixel extends KedaBasic implements IPixel {
|
|
|
|
|
|
|
|
|
|
export class KeDaMarker extends KedaBasic implements IMarker { |
|
|
|
|
public map: KeDaMap; |
|
|
|
|
public KedaMarkerID:String; |
|
|
|
|
public typeName: string = "KeDaMarker"; |
|
|
|
|
private html:string = '<img class="KedaPosImg" src="/assets/images/dingwei.png">' |
|
|
|
|
constructor(options: IMarkOptions) { |
|
|
|
|
super(); |
|
|
|
|
let pos = [] |
|
|
|
@ -257,43 +306,56 @@ export class KeDaMarker extends KedaBasic implements IMarker {
|
|
|
|
|
} else { |
|
|
|
|
pos = options.position.getArray() |
|
|
|
|
} |
|
|
|
|
let points = [{ |
|
|
|
|
point: pos, |
|
|
|
|
htmlText: null, |
|
|
|
|
}] |
|
|
|
|
let elementHtml = document.createElement('div') |
|
|
|
|
elementHtml.innerHTML = options.content? options.content : this.html |
|
|
|
|
let marker = { |
|
|
|
|
data: points, |
|
|
|
|
url: '/assets/images/dingwei.png', |
|
|
|
|
offset: options.offset ? options.offset.self : null, |
|
|
|
|
markerType: "KedaMarker", |
|
|
|
|
ended: (res) => { this.id = res.data; } |
|
|
|
|
point: pos, |
|
|
|
|
//anchor: 'bottom', //TODO
|
|
|
|
|
//offset: options.offset? options.offset.self : [0,0], //TODO
|
|
|
|
|
element: elementHtml.firstElementChild, |
|
|
|
|
ended: (res) => { |
|
|
|
|
this.KedaMarkerID = res.data; |
|
|
|
|
if (options.draggable) { //启用拖拽功能
|
|
|
|
|
this.map.self.setCustomOverlayDraggable({ |
|
|
|
|
id: this.KedaMarkerID, |
|
|
|
|
draggable: true, |
|
|
|
|
}) |
|
|
|
|
this.map.self.addEventOnCustomOverlays({ |
|
|
|
|
selector: `#${this.KedaMarkerID}`, |
|
|
|
|
event: 'dragend', |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
this.startBindEvent(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
this.self = marker; |
|
|
|
|
this._position = pos |
|
|
|
|
if (options.map) { |
|
|
|
|
this.map = options.map as KeDaMap |
|
|
|
|
this.map.self.addMarkers(this.self); |
|
|
|
|
this.map.self.addCustomOverlay(this.self); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
getLngLatByMarkerEvent(map:IMap,e: any): ILngLat { |
|
|
|
|
return e.lnglat; |
|
|
|
|
} |
|
|
|
|
_position: number[]; |
|
|
|
|
setContent(html: string) { //marker 添加 DOM元素
|
|
|
|
|
this.map.self.setMarkerProperty({ |
|
|
|
|
type: "markerType", |
|
|
|
|
markerType: "KedaMarker", |
|
|
|
|
points: [ |
|
|
|
|
{ htmlText: html } |
|
|
|
|
] |
|
|
|
|
this.map.self.setCustomOverlayProperty({ |
|
|
|
|
type: 'id', |
|
|
|
|
id: this.KedaMarkerID, |
|
|
|
|
element: html, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
setPosition(position: number[]) { |
|
|
|
|
this.map.self.setMarkerProperty({ |
|
|
|
|
type: "markerType", |
|
|
|
|
markerType: "KedaMarker", |
|
|
|
|
points: [position] |
|
|
|
|
setPosition(x: ILngLat | number[]) { |
|
|
|
|
x = (x as ILngLat).getArray == undefined ? x : (x as ILngLat).getArray(); |
|
|
|
|
this.map.self.setCustomOverlayProperty({ |
|
|
|
|
type: 'id', |
|
|
|
|
id: this.KedaMarkerID, |
|
|
|
|
point: x |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
setMap() { |
|
|
|
|
this.map.self.removeMarkersByType({ markerType: this.id }) |
|
|
|
|
this.map.self.removeCustomOverlayById({ id: this.KedaMarkerID }) |
|
|
|
|
} |
|
|
|
|
get id(): string { |
|
|
|
|
return this.self.id |
|
|
|
@ -311,16 +373,42 @@ export class KeDaMarker extends KedaBasic implements IMarker {
|
|
|
|
|
this.startBindEvent(); |
|
|
|
|
} |
|
|
|
|
startBindEvent() { |
|
|
|
|
let _this =this; |
|
|
|
|
if (this.map !== undefined) { |
|
|
|
|
this.bindObj.forEach((item, index) => { |
|
|
|
|
this.map.self.addEventOnMarkers({ |
|
|
|
|
selector: `.${this.id}`, |
|
|
|
|
if (item.eventName.includes('drag')) { |
|
|
|
|
this.map.self.setCustomOverlayDraggable({ |
|
|
|
|
id: this.KedaMarkerID, |
|
|
|
|
draggable: true, |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
this.map.self.addEventOnCustomOverlays({ |
|
|
|
|
selector: `#${this.KedaMarkerID}`, |
|
|
|
|
event: item.eventName, |
|
|
|
|
handler: (res) =>{ |
|
|
|
|
console.log(res,'marker点击') |
|
|
|
|
var d:ClickOptions = res.data.map(); |
|
|
|
|
d.target.id = this.self.id |
|
|
|
|
item.callback.call(item.component,d) |
|
|
|
|
this.map.self.getOverlayById({ |
|
|
|
|
id: this.KedaMarkerID, |
|
|
|
|
callback: (p)=>{ |
|
|
|
|
let point = p.data.point; |
|
|
|
|
let event |
|
|
|
|
if (res.lngLat!=undefined && res.point!=undefined) { |
|
|
|
|
event = { |
|
|
|
|
lnglat: new KeDaLngLat(point.lng,point.lat), |
|
|
|
|
pixel: [0,0],//科达覆盖物所用的div坐标为center,儿我们的div正好近似正方形,所以不用偏移
|
|
|
|
|
type: res.type, |
|
|
|
|
target: { id:this.self.id || null }, |
|
|
|
|
_target:res.target |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
event = { |
|
|
|
|
lnglat: new KeDaLngLat(point.lng,point.lat), |
|
|
|
|
target: { id:this.self.id || null } |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
item.callback.call(item.component,event) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
@ -358,7 +446,7 @@ export class KeDaLngLat extends KedaBasic implements ILngLat {
|
|
|
|
|
|
|
|
|
|
export class KedaDriving extends KedaBasic implements IDriving { //路线导航
|
|
|
|
|
public map: KeDaMap; |
|
|
|
|
public policy: number; // 0:快捷模式, 4:躲避拥堵
|
|
|
|
|
public policy: number = 0; // 0:快捷模式, 4:躲避拥堵
|
|
|
|
|
public id: string; |
|
|
|
|
constructor(options: any) { |
|
|
|
|
super(); |
|
|
|
@ -370,21 +458,28 @@ export class KedaDriving extends KedaBasic implements IDriving { //路线导航
|
|
|
|
|
startPoint: posStart.getArray(), |
|
|
|
|
endPoint: posEnd.getArray(), |
|
|
|
|
error: () => { alert('路线规划失败!') }, |
|
|
|
|
ended: (res) => {
|
|
|
|
|
ended: (res) => { |
|
|
|
|
console.log(res.data,'路径规划') |
|
|
|
|
this.id = res.data |
|
|
|
|
let router = { routes:[] } |
|
|
|
|
console.log(res.data) |
|
|
|
|
callback.call(component,'complete',router) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (this.policy === 0) { //快捷模式
|
|
|
|
|
this.map.self.createMinDistanceRoutePlanning(params) |
|
|
|
|
} else { //躲避拥堵
|
|
|
|
|
this.map.self.createMinTimeRoutePlanning(params) |
|
|
|
|
if (this.map.isLoadEnd) { //map加载完毕
|
|
|
|
|
if (this.policy === 0) { //快捷模式
|
|
|
|
|
this.map.self.createMinDistanceRoutePlanning(params) |
|
|
|
|
} else { //躲避拥堵
|
|
|
|
|
this.map.self.createMinTimeRoutePlanning(params) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
let _this =this; |
|
|
|
|
this.map.LoadedCallback.push( |
|
|
|
|
()=>_this.search(component,posStart,posEnd,callback)
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
clear() { |
|
|
|
|
this.map.self.removeRoutePlanning({ id: this.id }) |
|
|
|
|
this.id? this.map.self.removeRoutePlanning({ id: this.id }) : null |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -404,6 +499,7 @@ export class KedaAutocomplete extends KedaBasic implements IAutocomplete { //Aut
|
|
|
|
|
(this.component.map as KeDaMap).self.queryInfoByType({ |
|
|
|
|
code: cityCode, |
|
|
|
|
keyword: this.$input.value, |
|
|
|
|
maxCount: 10, |
|
|
|
|
searchType: [], |
|
|
|
|
callback: (res) => { |
|
|
|
|
let list = res.data |
|
|
|
@ -414,19 +510,40 @@ export class KedaAutocomplete extends KedaBasic implements IAutocomplete { //Aut
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
on(eventName: string, callback: AutocompleteSelectCallback) { |
|
|
|
|
this.searchDownList.setClickHander(e => { |
|
|
|
|
console.log(e+'Keda') |
|
|
|
|
callback.call(this.component,e); |
|
|
|
|
this.searchDownList.setClickHander((e:any) => { |
|
|
|
|
let a = { |
|
|
|
|
id : e.id, |
|
|
|
|
name : e.name, |
|
|
|
|
adcode : e.adminId, |
|
|
|
|
district : e.address, |
|
|
|
|
location : new KeDaLngLat(e.locationpoint[0],e.locationpoint[1]), |
|
|
|
|
type : 'point', |
|
|
|
|
poi: { location : new KeDaLngLat(e.locationpoint[0],e.locationpoint[1]) } |
|
|
|
|
} |
|
|
|
|
callback.call(this.component,a); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
search(address: string, callback: AutocompleteSearchCallback) { |
|
|
|
|
(this.component.map as KeDaMap).self.queryInfoByType({ |
|
|
|
|
code: cityCode, |
|
|
|
|
keyword: address, |
|
|
|
|
maxCount: 10, |
|
|
|
|
searchType: [], |
|
|
|
|
callback: (res) => { |
|
|
|
|
console.log(res) |
|
|
|
|
callback.call(this.component,'complete',res); |
|
|
|
|
callback: (res:any) => { |
|
|
|
|
let list = { tips:[] }; |
|
|
|
|
res.data.forEach(item => { |
|
|
|
|
let a = { |
|
|
|
|
id : item.id, |
|
|
|
|
name : item.name, |
|
|
|
|
adcode : item.adminId, |
|
|
|
|
district : item.address, |
|
|
|
|
location : new KeDaLngLat(item.locationpoint[0],item.locationpoint[1]), |
|
|
|
|
type : 'point', |
|
|
|
|
poi: { location : new KeDaLngLat(item.locationpoint[0],item.locationpoint[1]) } |
|
|
|
|
} |
|
|
|
|
list.tips.push(a); |
|
|
|
|
}); |
|
|
|
|
callback.call(this.component,'complete',list); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
@ -442,10 +559,23 @@ export class KedaPlaceSearch extends KedaBasic implements IPlaceSearch { //Place
|
|
|
|
|
(this.component.map as KeDaMap).self.queryInfoByType({ |
|
|
|
|
code: cityCode, |
|
|
|
|
keyword: address, |
|
|
|
|
maxCount: 10, |
|
|
|
|
searchType: [], |
|
|
|
|
callback: (res) => { |
|
|
|
|
console.log(res) |
|
|
|
|
callback.call(this.component,'complete',res); |
|
|
|
|
callback: (res:any) => { |
|
|
|
|
let list = { info:'OK', poiList:{ posi:[] } }; |
|
|
|
|
res.data.forEach(item => { |
|
|
|
|
let a = { |
|
|
|
|
id : item.id, |
|
|
|
|
name : item.name, |
|
|
|
|
adcode : item.adminId, |
|
|
|
|
district : item.address, |
|
|
|
|
location : new KeDaLngLat(item.locationpoint[0],item.locationpoint[1]), |
|
|
|
|
type : 'point', |
|
|
|
|
poi: { location : new KeDaLngLat(item.locationpoint[0],item.locationpoint[1]) } |
|
|
|
|
} |
|
|
|
|
list.poiList.posi.push(a); |
|
|
|
|
}); |
|
|
|
|
callback.call(this.component,'complete',list); |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
@ -478,7 +608,7 @@ export class KedaCircle extends KedaBasic implements ICircle { //圆形 图层
|
|
|
|
|
}, |
|
|
|
|
radius: 0, |
|
|
|
|
draggable: false, |
|
|
|
|
updateHandler: (res) => { console.log(res) }, |
|
|
|
|
updateHandler: (res) => { }, |
|
|
|
|
end: (res) => { this.id = res } |
|
|
|
|
} |
|
|
|
|
this.self = circle |
|
|
|
@ -489,75 +619,93 @@ export class KedaCircle extends KedaBasic implements ICircle { //圆形 图层
|
|
|
|
|
setCenter(pos: number[]) {//设置圆的中心
|
|
|
|
|
this.self.center = pos |
|
|
|
|
} |
|
|
|
|
setMap(map: IMap) {//把圆添加到 map
|
|
|
|
|
map.self.addGeometryCircleLayer(this.self) |
|
|
|
|
setMap(map: KeDaMap) {//把圆添加到 map
|
|
|
|
|
if (map.isLoadEnd) { |
|
|
|
|
this.self.radius != 0 && map.self.addGeometryCircleLayer(this.self) |
|
|
|
|
} else { |
|
|
|
|
let _this =this; |
|
|
|
|
map.LoadedCallback.push( |
|
|
|
|
()=>_this.setMap(map)
|
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export class KedaMarkerCluster extends KedaBasic implements IMarkerCluster { //Marker 聚合物
|
|
|
|
|
public map:KeDaMap |
|
|
|
|
public id:string |
|
|
|
|
private LoadedCallback:Function[] = [] |
|
|
|
|
public markerList:any[] = [] |
|
|
|
|
constructor(map: IMap, list: Object[], options: any) { |
|
|
|
|
super(); |
|
|
|
|
this.map = map |
|
|
|
|
console.log(list,options,'聚合物配置') |
|
|
|
|
//聚合图层
|
|
|
|
|
this.map.self.addCustomLayer({ |
|
|
|
|
serviceName:'service_tzn_test7', //图层类型
|
|
|
|
|
isPublic: true, //是否查询纯公有空间数据
|
|
|
|
|
icons: [ //数据源属性匹配非聚合图标 icon
|
|
|
|
|
{ |
|
|
|
|
iconName: 'car-15', |
|
|
|
|
filter: [], |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
clustered: true, //是否聚合
|
|
|
|
|
clusteredFilters: [ //聚合条件
|
|
|
|
|
{//1-10
|
|
|
|
|
count: 1, |
|
|
|
|
circleColor: '#51bbd6', |
|
|
|
|
circleRadius: 20 //圆的半径
|
|
|
|
|
}, |
|
|
|
|
{//10-100
|
|
|
|
|
count: 10, |
|
|
|
|
circleColor: '#f1f075', |
|
|
|
|
circleRadius: 30 |
|
|
|
|
}, |
|
|
|
|
{//100以上
|
|
|
|
|
count: 100, |
|
|
|
|
circleColor: '#f28cb1', |
|
|
|
|
circleRadius: 35 |
|
|
|
|
} |
|
|
|
|
], |
|
|
|
|
ended: (res) => { if (res.status === 10) { this.id = res.data } } |
|
|
|
|
}); //add
|
|
|
|
|
this.map = map as KeDaMap; |
|
|
|
|
list.forEach((item:any)=>{ |
|
|
|
|
let elementHtml = document.createElement('div') |
|
|
|
|
elementHtml.innerHTML = `<img class="KedaPosIcon" src="${item.image}">` |
|
|
|
|
let marker = { |
|
|
|
|
point: item.lnglat, |
|
|
|
|
element: elementHtml.firstElementChild, |
|
|
|
|
customProps: item.data, |
|
|
|
|
} |
|
|
|
|
this.markerList.push(marker) |
|
|
|
|
}) |
|
|
|
|
if (this.markerList.length) { //有聚合物时
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
// let http:HttpClient = global.injector.get<HttpClient>(HttpClient)
|
|
|
|
|
// http.get(`http://10.14.183.81/kiop-web/static/autoGroup/2.19.0.kd/assets/json/buildData.json`).subscribe(data=>{
|
|
|
|
|
// console.log(data)
|
|
|
|
|
// })
|
|
|
|
|
//覆盖物聚合
|
|
|
|
|
// this.map.self.addOverlayLayer({
|
|
|
|
|
// serviceName: 'service_tzn_test3', //业务图层类型
|
|
|
|
|
// clustered: true, //是否聚合
|
|
|
|
|
// defaultIcon: 'icon-policeman-1',//雪碧图名称
|
|
|
|
|
// clusteredMarkerTemplate: `'<div style="background-color: lightgrey;padding: 4px;border-radius: 3px">' +
|
|
|
|
|
// '{{IMGTAG}}' +</div>`,
|
|
|
|
|
// singleMarkerTemplate: {
|
|
|
|
|
// default: '<div style="background-color: red;padding: 2px;border-radius: 3px">' +
|
|
|
|
|
// '{{IMGTAG}}' + '</div>',
|
|
|
|
|
// filters: [
|
|
|
|
|
// {
|
|
|
|
|
// template: '<div style="background-color: red;padding: 2px;border-radius: 3px">' +
|
|
|
|
|
// '{{IMGTAG}}' +
|
|
|
|
|
// '</div>',
|
|
|
|
|
// icon: 'icon-policeman-1',
|
|
|
|
|
// //status === 1 的数据,将显示为markerHtml的marker样式
|
|
|
|
|
// match: [{
|
|
|
|
|
// key: 'status',
|
|
|
|
|
// value: 1
|
|
|
|
|
// }]
|
|
|
|
|
// },
|
|
|
|
|
// ]
|
|
|
|
|
// },
|
|
|
|
|
// ended: function (res) {
|
|
|
|
|
// console.log(res,'覆盖物聚合·')
|
|
|
|
|
// this.id = res.data
|
|
|
|
|
// this.LoadedCallback.forEach(i=>{
|
|
|
|
|
// try{
|
|
|
|
|
// i();
|
|
|
|
|
// }catch(e) {
|
|
|
|
|
// console.log(e,'错误')
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// this.LoadedCallback = []
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
} |
|
|
|
|
on(eventName: string, callback: MarkerClusterCallback, component?: any): void { |
|
|
|
|
// 绑定聚合事件时获取信息
|
|
|
|
|
this.map.self.addEventOnLayerObject({ |
|
|
|
|
layerId: this.id, |
|
|
|
|
event: eventName, |
|
|
|
|
handler: (e, info) => { |
|
|
|
|
//查询聚合详情
|
|
|
|
|
if (info.type === 'aggs') { |
|
|
|
|
this.map.self.queryClusterDetail({ |
|
|
|
|
queryOptions: info, |
|
|
|
|
serviceName: 'service_tzn_test7', |
|
|
|
|
maxCount: 999, |
|
|
|
|
callback: function (res) { |
|
|
|
|
console.log(res, '聚合详情'); |
|
|
|
|
callback.call(component,res) |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} else if (info.type === 'details') { |
|
|
|
|
console.log(info.data,'聚合详情'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
let _this =this; |
|
|
|
|
if(!this.id){ |
|
|
|
|
this.LoadedCallback.push( |
|
|
|
|
()=>_this.on(eventName,callback,component)
|
|
|
|
|
); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
setData(list: any[]) { |
|
|
|
|
if (!list.length) { |
|
|
|
|
this.map.self.removeLayer({layerId: this.id}); |
|
|
|
|
if (!list.length && this.id) { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -582,6 +730,7 @@ export class KedaInfoWindow extends KedaBasic implements IInfoWindow { //信息
|
|
|
|
|
super(); |
|
|
|
|
let opt = { |
|
|
|
|
htmlText: options.content, |
|
|
|
|
// offset: options.offset.self,
|
|
|
|
|
anchor: 'bottom', |
|
|
|
|
point: options.position, |
|
|
|
|
closeButton: true, |
|
|
|
@ -638,7 +787,6 @@ export class KedaMouseTool extends KedaBasic implements IMouseTool { //地图工
|
|
|
|
|
}], |
|
|
|
|
anchor: 'left', |
|
|
|
|
ended: function (res) { |
|
|
|
|
console.log(res); |
|
|
|
|
that.layerIds.push(res.data); |
|
|
|
|
startText = res.data; |
|
|
|
|
} |
|
|
|
@ -652,7 +800,6 @@ export class KedaMouseTool extends KedaBasic implements IMouseTool { //地图工
|
|
|
|
|
}], |
|
|
|
|
anchor: 'left', |
|
|
|
|
ended: function (res) { |
|
|
|
|
console.log(res); |
|
|
|
|
that.layerIds.push(res.data); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -678,7 +825,6 @@ export class KedaMouseTool extends KedaBasic implements IMouseTool { //地图工
|
|
|
|
|
}], |
|
|
|
|
anchor: 'left', |
|
|
|
|
ended: function (res) { |
|
|
|
|
console.log(res); |
|
|
|
|
that.layerIds.push(res.data); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -711,7 +857,6 @@ export class KedaMouseTool extends KedaBasic implements IMouseTool { //地图工
|
|
|
|
|
}], |
|
|
|
|
anchor: 'left', |
|
|
|
|
ended: function (res) { |
|
|
|
|
console.log(res); |
|
|
|
|
that.layerIdAreas.push(res.data); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
@ -736,7 +881,6 @@ export class KedaMouseTool extends KedaBasic implements IMouseTool { //地图工
|
|
|
|
|
}], |
|
|
|
|
anchor: 'left', |
|
|
|
|
ended: function (res) { |
|
|
|
|
console.log(res); |
|
|
|
|
that.layerIdAreas.push(res.data); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|