【发布时间】:2021-03-18 23:30:27
【问题描述】:
我将this wrapper 用于天蓝色地图库。我目前正在实现symbol layer,并且使用其中一个默认标记效果很好,但我无法添加自己的标记。我尝试在 mapReady 函数中添加自定义标记,但响应始终未定义且未添加图像。
这是我的组件:
import {Component, Input, OnInit} from '@angular/core';
import * as atlas from 'azure-maps-control';
@Component({
selector: 'app-map',
templateUrl: './map.component.html',
styleUrls: ['./map.component.scss']
})
export class MapComponent implements OnInit {
private markerImagePath = 'assets/images/map-marker.png';
public dataSource: atlas.source.DataSource;
markerDescription: 'marker';
public options: atlas.IconOptions = {
image: this.markerDescription
};
points = [
[52.52437, 13.41053],
[51.50853, -0.12574]
];
ngOnInit() { }
mapReady(map: atlas.Map) {
map.imageSprite.add(this.markerDescription, this.markerImagePath).then(r => {
console.log(r);
console.log(map.imageSprite.getImageIds());
this.dataSource = new atlas.source.DataSource('markers');
this.points.forEach(p => {
const point = new atlas.Shape(new atlas.data.Point([p[1], p[0]]));
this.dataSource.add([point]);
});
});
}
}
这是我的html:
<section>
<div class="row">
<div class="col-12 map-dimensions my-2 mx-auto" azure-map zoom="2"
[dataSources]="[dataSource]" (onReady)="mapReady($event.map)">
<map-symbol-layer dataSourceId="markers"
[iconOptions]="options"></map-symbol-layer>
</div>
</div>
</section>
我怀疑我错误地访问了地图数据...你们有谁知道,我如何将自定义图像添加到 imageSprites 以便我将其用作符号层中的标记?
【问题讨论】:
标签: azure azure-maps