This is a migrated thread and some comments may be shown as answers.

Selecting all shapes

2 Answers 92 Views
Map
This is a migrated thread and some comments may be shown as answers.
arno
Top achievements
Rank 1
arno asked on 09 Jul 2015, 02:48 PM

Hi,

I am attempting to select all shapes in order to apply a new color to all of them.
I started off with the kendo geojson demo for the map where a color is applied to every country (shape) when created using the shapeCreated event.

shapeCreated= function(e){
        var shape = e.shape;
        var users = shape.dataItem.properties.users;
        var scale = chroma.scale(["white", "green"]).domain([1, 1000]);
        if (users) {
            var color = scale(users).hex();
            shape.options.fill.set("color", color);
        }
    }

but I don't find a way to now change this once the shape is created.How do I loop through the shapes and apply a new color?

Also, the normal charts have .redraw() and refresh() methods, the map doesn't seem to have something like this? How do I refresh the map when something fundamental changes?

Thanks in advance,

Arno

 

2 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 13 Jul 2015, 10:53 AM
Hello,

The shape references that you receive in shapeCreated remain live until the next time the map is reset or new data comes in through the layer data source.
You can store the references and reapply changes to all properties later:
var shapes = [];
shapeCreated: function(e) {
  shapes.push(e.shape);
  ...
}

...

shapes[1].fill("red");

Changes to widget settings should go through setOptions. There is no need for a redraw or refresh call.

I hope this helps.

Regards,
T. Tsonev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
arno
Top achievements
Rank 1
answered on 15 Jul 2015, 10:25 AM

Ha ok, never used the setOptions, will have a look.

thank you!

Tags
Map
Asked by
arno
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
arno
Top achievements
Rank 1
Share this question
or