-3

I'm using @agm/core for my project and I want the data layer to style dynamically.

  1. When I click on the single layer it has to change the color. This is done using data layer click functionality
  2. When I select a radio button or a check box then the whole data layers has to get updated with a different color which is not happening.

Trying to complete the task with the changes but haven't found any help.

f.khantsis
  • 3,256
  • 5
  • 50
  • 67
  • 2
    See [ask]. You aren't going to get much traction without a [mcve]. And you also need to tell us what your expected and real results were. –  Feb 22 '19 at 21:42

1 Answers1

0

You can simply share a style object between data layers:

// HTML
<agm-data-layer [geoJson]="geoJsonObject" [style]="styleObject"></agm-data-layer>
<agm-data-layer [geoJson]="geoJsonObject2" [style]="styleObject"></agm-data-layer>

// TS
public styleObject = {
  clickable: true,
  fillColor: "#FFFFFF",
  strokeWeight: 0
};

public changeStyle() {
  this.style = {...this.style, fillColor: "#000000"};
}
velo
  • 53
  • 1
  • 4