【发布时间】:2020-07-17 22:13:33
【问题描述】:
我需要通过三个不同的按钮来改变两个圆圈的颜色,分别是红色、蓝色和绿色。
我有:
app.module.ts
import { NgModule } from '@angular/core';
import { AgmCoreModule } from '@agm/core';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
// Imposta qui le tue api key
AgmCoreModule.forRoot({apiKey: 'GOOGLE_MAPS_API'}),
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'map server';
lat: number = 45.464198;
lng: number = 9.190545;
lat2: number = 45.464198;
lng2: number = 9.190545;
}
app.component.html
{{title}}
<agm-map [latitude]="lat" [longitude]="lng">
<agm-marker [latitude]="lat" [longitude]="lng" >
</agm-marker>
<agm-circle [latitude]="lat" [longitude]="lng"
[radius]="5000"
[fillColor]="'red'">
</agm-circle>
<agm-circle [latitude]="lat2" [longitude]="lng2"
[radius]="7000"
[fillColor]="'green'">
</agm-circle>
</agm-map>
和
app.component.css
agm-map
{
height: 600px;
}
【问题讨论】:
-
你得到什么错误?
-
我没有任何错误,我只需要知道如何添加这些按钮并更改颜色
-
所以你想在点击时改变两个圆圈的颜色?
-
成功了吗??
标签: angular