|
|
|
@ -14,7 +14,7 @@ export class GaoDeMap extends GaodeBasic implements IMap {
|
|
|
|
|
this.self = new AMap.Map(container, options); |
|
|
|
|
} |
|
|
|
|
setBounds(zoom?: any, x?: any, y?: any, is?: boolean) { |
|
|
|
|
return this.self.setBounds(zoom,x,y,is) |
|
|
|
|
return this.self.setBounds(zoom, x, y, is) |
|
|
|
|
} |
|
|
|
|
setFitView(options: any) { |
|
|
|
|
return this.self.setFitView(options) |
|
|
|
@ -52,7 +52,7 @@ export class GaoDeMap extends GaodeBasic implements IMap {
|
|
|
|
|
setZoom(zoom) { |
|
|
|
|
return this.self.setZoom(zoom) |
|
|
|
|
} |
|
|
|
|
setCenter(pos:any) { |
|
|
|
|
setCenter(pos: any) { |
|
|
|
|
return this.self.setCenter(pos) |
|
|
|
|
} |
|
|
|
|
getCenter() { |
|
|
|
@ -64,10 +64,10 @@ export class GaoDeMap extends GaodeBasic implements IMap {
|
|
|
|
|
on(eventName: string, callback: Function): void { |
|
|
|
|
return this.self.on(eventName, callback); |
|
|
|
|
} |
|
|
|
|
setAdministrativeAreaStyle(component:any,getData?:Function, setData?:Function) {//自定义 行政区划 样式
|
|
|
|
|
setAdministrativeAreaStyle(component: any, getData?: Function, setData?: Function) {//自定义 行政区划 样式
|
|
|
|
|
let that = this |
|
|
|
|
let level = sessionStorage.getItem("level") |
|
|
|
|
AMapUI.loadUI(['geo/DistrictExplorer'], (DistrictExplorer)=> { |
|
|
|
|
AMapUI.loadUI(['geo/DistrictExplorer'], (DistrictExplorer) => { |
|
|
|
|
|
|
|
|
|
let colors = [ |
|
|
|
|
"#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00", |
|
|
|
@ -82,7 +82,7 @@ export class GaoDeMap extends GaodeBasic implements IMap {
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
let adcode = 310000 //上海行政编码
|
|
|
|
|
districtExplorer.loadAreaNode(adcode, (error, areaNode)=> { |
|
|
|
|
districtExplorer.loadAreaNode(adcode, (error, areaNode) => { |
|
|
|
|
|
|
|
|
|
//更新地图视野
|
|
|
|
|
that.setBounds(areaNode.getBounds(), null, null, true); |
|
|
|
@ -95,7 +95,7 @@ export class GaoDeMap extends GaodeBasic implements IMap {
|
|
|
|
|
districtExplorer.clearFeaturePolygons(); |
|
|
|
|
|
|
|
|
|
//绘制子区域
|
|
|
|
|
districtExplorer.renderSubFeatures(areaNode, (feature, i) =>{ |
|
|
|
|
districtExplorer.renderSubFeatures(areaNode, (feature, i) => { |
|
|
|
|
let fillColor = colors[i % colors.length]; |
|
|
|
|
let strokeColor = colors[colors.length - 1 - i % colors.length]; |
|
|
|
|
return { |
|
|
|
@ -124,101 +124,101 @@ export class GaoDeMap extends GaodeBasic implements IMap {
|
|
|
|
|
that.setFitView(districtExplorer.getAllFeaturePolygons()); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if(level=="0"||level=="1"||level=="2"){ |
|
|
|
|
if (level == "0" || level == "1" || level == "2") { |
|
|
|
|
//区域内点击
|
|
|
|
|
districtExplorer.on('featureClick', (e, feature) =>{ |
|
|
|
|
getData && getData(feature); |
|
|
|
|
|
|
|
|
|
let props = feature.properties; |
|
|
|
|
adcode = props.adcode |
|
|
|
|
let fillColor2 |
|
|
|
|
if(props.level == 'city'){ |
|
|
|
|
fillColor2 = null |
|
|
|
|
}else{ |
|
|
|
|
fillColor2 = '#d0daee' |
|
|
|
|
} |
|
|
|
|
districtExplorer.loadAreaNode(adcode, (error, areaNode)=> { |
|
|
|
|
|
|
|
|
|
//设置定位节点,支持鼠标位置识别
|
|
|
|
|
//注意节点的顺序,前面的高优先级
|
|
|
|
|
districtExplorer.setAreaNodesForLocating(areaNode); |
|
|
|
|
|
|
|
|
|
//清除已有的绘制内容
|
|
|
|
|
districtExplorer.clearFeaturePolygons(); |
|
|
|
|
|
|
|
|
|
//绘制子区域
|
|
|
|
|
districtExplorer.renderSubFeatures(areaNode, (feature, i) =>{ |
|
|
|
|
let fillColor = colors[i % colors.length]; |
|
|
|
|
let strokeColor = colors[colors.length - 1 - i % colors.length]; |
|
|
|
|
return { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: strokeColor, //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: fillColor, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//绘制父区域
|
|
|
|
|
districtExplorer.renderParentFeature(areaNode, { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: 'black', //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: fillColor2, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
districtExplorer.on('featureClick', (e, feature) => { |
|
|
|
|
getData && getData.call(component, feature); |
|
|
|
|
|
|
|
|
|
let props = feature.properties; |
|
|
|
|
adcode = props.adcode |
|
|
|
|
let fillColor2 |
|
|
|
|
if (props.level == 'city') { |
|
|
|
|
fillColor2 = null |
|
|
|
|
} else { |
|
|
|
|
fillColor2 = '#d0daee' |
|
|
|
|
} |
|
|
|
|
districtExplorer.loadAreaNode(adcode, (error, areaNode) => { |
|
|
|
|
|
|
|
|
|
//设置定位节点,支持鼠标位置识别
|
|
|
|
|
//注意节点的顺序,前面的高优先级
|
|
|
|
|
districtExplorer.setAreaNodesForLocating(areaNode); |
|
|
|
|
|
|
|
|
|
//清除已有的绘制内容
|
|
|
|
|
districtExplorer.clearFeaturePolygons(); |
|
|
|
|
|
|
|
|
|
//绘制子区域
|
|
|
|
|
districtExplorer.renderSubFeatures(areaNode, (feature, i) => { |
|
|
|
|
let fillColor = colors[i % colors.length]; |
|
|
|
|
let strokeColor = colors[colors.length - 1 - i % colors.length]; |
|
|
|
|
return { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: strokeColor, //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: fillColor, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//绘制父区域
|
|
|
|
|
districtExplorer.renderParentFeature(areaNode, { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: 'black', //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: fillColor2, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 更新地图视野以适合区划面
|
|
|
|
|
that.setFitView(districtExplorer.getAllFeaturePolygons()); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 更新地图视野以适合区划面
|
|
|
|
|
that.setFitView(districtExplorer.getAllFeaturePolygons()); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
districtExplorer.on('outsideClick', (e) => { |
|
|
|
|
setData && setData(component); |
|
|
|
|
let adcode = 310000 |
|
|
|
|
districtExplorer.loadAreaNode(adcode, (error, areaNode)=> { |
|
|
|
|
|
|
|
|
|
//设置定位节点,支持鼠标位置识别
|
|
|
|
|
//注意节点的顺序,前面的高优先级
|
|
|
|
|
districtExplorer.setAreaNodesForLocating(areaNode); |
|
|
|
|
|
|
|
|
|
//清除已有的绘制内容
|
|
|
|
|
districtExplorer.clearFeaturePolygons(); |
|
|
|
|
|
|
|
|
|
//绘制子区域
|
|
|
|
|
districtExplorer.renderSubFeatures(areaNode, (feature, i) =>{ |
|
|
|
|
let fillColor = colors[i % colors.length]; |
|
|
|
|
let strokeColor = colors[colors.length - 1 - i % colors.length]; |
|
|
|
|
return { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: strokeColor, //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: fillColor, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//绘制父区域
|
|
|
|
|
districtExplorer.renderParentFeature(areaNode, { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: 'black', //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: null, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 更新地图视野以适合区划面
|
|
|
|
|
that.setFitView(districtExplorer.getAllFeaturePolygons()); |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
districtExplorer.on('outsideClick', (e) => { |
|
|
|
|
setData && setData.call(component); |
|
|
|
|
let adcode = 310000 |
|
|
|
|
districtExplorer.loadAreaNode(adcode, (error, areaNode) => { |
|
|
|
|
|
|
|
|
|
//设置定位节点,支持鼠标位置识别
|
|
|
|
|
//注意节点的顺序,前面的高优先级
|
|
|
|
|
districtExplorer.setAreaNodesForLocating(areaNode); |
|
|
|
|
|
|
|
|
|
//清除已有的绘制内容
|
|
|
|
|
districtExplorer.clearFeaturePolygons(); |
|
|
|
|
|
|
|
|
|
//绘制子区域
|
|
|
|
|
districtExplorer.renderSubFeatures(areaNode, (feature, i) => { |
|
|
|
|
let fillColor = colors[i % colors.length]; |
|
|
|
|
let strokeColor = colors[colors.length - 1 - i % colors.length]; |
|
|
|
|
return { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: strokeColor, //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: fillColor, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//绘制父区域
|
|
|
|
|
districtExplorer.renderParentFeature(areaNode, { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: 'black', //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: null, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 更新地图视野以适合区划面
|
|
|
|
|
that.setFitView(districtExplorer.getAllFeaturePolygons()); |
|
|
|
|
}); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}); //end
|
|
|
|
@ -360,7 +360,7 @@ export class GaodePlaceSearch extends GaodeBasic implements IPlaceSearch {
|
|
|
|
|
this.self = new AMap.PlaceSearch() |
|
|
|
|
} |
|
|
|
|
search(text: string, callback: Function) { |
|
|
|
|
return this.self.search(text,callback) |
|
|
|
|
return this.self.search(text, callback) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|