Merge branch 'develop' of https://gitlab.eascs.com/tms-ui/tms-obc-web into develop

This commit is contained in:
wangshiming
2021-12-07 09:50:47 +08:00

View File

@ -4,6 +4,7 @@ import { load } from '@amap/amap-jsapi-loader';
import { BaseService } from 'src/app/shared/services'; import { BaseService } from 'src/app/shared/services';
import { throwError } from 'rxjs'; import { throwError } from 'rxjs';
import AMapLoader from '@amap/amap-jsapi-loader'; import AMapLoader from '@amap/amap-jsapi-loader';
declare var AMapUI: any;
@Component({ @Component({
selector: 'app-gaode-map', selector: 'app-gaode-map',
templateUrl: './gaode-map.component.html' templateUrl: './gaode-map.component.html'
@ -25,12 +26,15 @@ export class GaodeMapComponent implements OnInit, OnDestroy {
} }
mapInit() { mapInit() {
console.log(AMapLoader);
AMapLoader.load({ AMapLoader.load({
// 首次调用 load // 首次调用 load
key: '63f9573ca55fef2b92d4ffe0c85dea8f', // 申请好的Web端开发者Key首次调用 load 时必填 key: '63f9573ca55fef2b92d4ffe0c85dea8f', // 申请好的Web端开发者Key首次调用 load 时必填
version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15 version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: [ plugins: [
// 需要使用的的插件列表,如比例尺'AMap.Scale'等 // 需要使用的的插件列表,如比例尺'AMap.Scale'等
'AMap.SimpleMarker',
'AMap.Scale', 'AMap.Scale',
'AMap.ToolBar', 'AMap.ToolBar',
'AMap.MapType', 'AMap.MapType',
@ -40,7 +44,7 @@ export class GaodeMapComponent implements OnInit, OnDestroy {
AMapUI: { AMapUI: {
// 是否加载 AMapUI缺省不加载 // 是否加载 AMapUI缺省不加载
version: '1.1', // AMapUI 缺省 1.1 version: '1.1', // AMapUI 缺省 1.1
plugins: [] // 需要加载的 AMapUI ui插件 plugins: ['overlay/SimpleMarker'] // 需要加载的 AMapUI ui插件
}, },
Loca: { Loca: {
// 是否加载 Loca 缺省不加载 // 是否加载 Loca 缺省不加载
@ -50,12 +54,21 @@ export class GaodeMapComponent implements OnInit, OnDestroy {
.then(AMap => { .then(AMap => {
console.log(AMap); console.log(AMap);
this.aMap = new AMap.Map('container', { this.aMap = new AMap.Map('container');
viewMode: '2D', // 默认使用 2D 模式,如果希望使用带有俯仰角的 3D 模式,请设置 viewMode: '3D', console.log(this.aMap);
zoom: 16
});
this.aMap.on('complete', () => { this.aMap.on('complete', () => {
this.service.msgSrv.info('地图加载完成 !'); this.service.msgSrv.info('地图加载完成 !');
new AMapUI.SimpleMarker({
//前景文字
iconLabel: 'A',
//图标主题
iconTheme: 'default',
//背景图标样式
iconStyle: 'red',
map: this.aMap,
position: this.aMap.getCenter()
});
}); });
}) })
.catch(e => { .catch(e => {