We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Replacing layers doesn't fully replace.


I have a component with maps. Within this component the user can switch between 2 layers.
So very simple, one layer needs to replace the entire existing layer. But doing that doesnt work upon initial function call, it only works upon the second (same)function call.
After the initial call, it seems that it has replaced everything except for shapeData visually -> (and yes, xxx.refresh() is being called).  I came to this conclusion because of 1st function call switching to layer2 to layer1 and then hovering over the shape. It will return errors when hovering(except for a few on the rightside) trying to find the property belonging to the shape).

I have created a stackblits for testing/replicating. -> just select the same layer twice from the dropdown.

Any idea why this is happening?



1 Reply

BP Baby Palanidurai Syncfusion Team May 30, 2019 01:15 PM UTC

Hi Laurens, 
Greetings from Syncfusion. 
We have analysed your scenario. In your scenario, you have switched the layers by using mapLayers as object. In our source onPropertyChanged method only called for background, width and height properties of the maps and not for layers property. So, you can change the layers from maps instance like this.maps.layers and then call this.maps.refresh(). We have modified your sample and attached in below location for your reference.  
And also given the code snippet for your reference. 
Code snippet- 
  swLayer(args: any) { 
    if (args.name === "layer1") { 
      this.maps.layers = this.layer1; 
      // this.mapLayers = this.layer1; 
    else { 
      this.maps.layers = this.layer2; 
      // this.mapLayers = this.layer2; 

Live Chat Icon For mobile
Up arrow icon