1
我正在使用Agm在地图上显示位置,它的工作完美到目前为止,但现在我还需要显示方向,就像在导航过程中链接地图中两点的线一样,我查看了文档,但没有显示太多内容。
谢谢在谷歌地图上显示角度2的方向Agm
我正在使用Agm在地图上显示位置,它的工作完美到目前为止,但现在我还需要显示方向,就像在导航过程中链接地图中两点的线一样,我查看了文档,但没有显示太多内容。
谢谢在谷歌地图上显示角度2的方向Agm
agm-direction可以帮助你
STEP.1安装AGM
npm install --save @agm/core
step.2安装AGM-方向
npm install --save agm-direction
STEP.3开始导入模块
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';
import { AgmCoreModule } from '@agm/core';
import { AgmDirectionModule } from 'agm-direction';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
AgmCoreModule.forRoot({ // @agm/core
apiKey: 'your key',
}),
AgmDirectionModule // agm-direction
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
step.4 HTML
<agm-map [latitude]="lat" [longitude]="lng">
<agm-direction *ngIf="dir" [origin]="dir.origin" [destination]="dir.destination"></agm-direction>
</agm-map>
step.5打字稿
lat: Number = 24.799448;
lng: Number = 120.979021;
zoom: Number = 14;
dir = undefined;
public getDirection() {
this.dir = {
origin: { lat: 24.799448, lng: 120.979021 },
destination: { lat: 24.799524, lng: 120.975017 }
}
}
属性
尽管这个链接可能回答这个问题,但最好在这里包含答案的重要部分,并提供供参考的链接。如果链接页面更改,则仅链接答案可能会失效。 - [来自评论](/ review/low-quality-posts/18098978) –