我从Map.ts中的此函数正确地得到了协调:
populateForm() {
let pharmaId = this.route.snapshot.params["id"];
this.pharma.pharmagetbyid(pharmaId ).subscribe(
pharmadata=> {
if (pharmadata){
this.pharmadata= pharmadata;
}
}
);
}
在html中,我在Map.html中编写以下代码:
<Mapbox
accessToken="pk.xxxxxxxxxxxxxxx"
mapStyle="traffic_day"
[latitude]="pharmadata.latitude"
[longitude]="pharmadata.longitude"
zoomLevel="7"
delay="450"
showUserLocation="true"
hideCompass="false"
disableZoom="false"
disableRotation="false"
disableScroll="false"
disableTilt="false"
(mapReady)="onMapReady($event)">
</Mapbox>
此onMapReady()在Map.ts中具有以下代码:
onMapReady(args): void {
this.map = args.map;
console.log(args.map)
this.map.addMarkers([
{
lat: this.pharmadata.longitude,
lng: this.pharmadata.latitude,
}
]
);
}
我的坐标是:
“经度”:4.56,“纬度”:5.65
您能建议我任何只显示商标的想法吗?
答案 0 :(得分:0)
您的经纬度在onMapReady
函数中被翻转。您的代码应如下所示:
onMapReady(args): void {
this.map = args.map;
console.log(args.map)
this.map.addMarkers([
{
lat: this.pharmadata.latitude, // Flip these
lng: this.pharmadata.longitude, // two lines
}
]
);
}