Selecting all shapes

3 posts, 0 answers
  1. arno
    arno avatar
    14 posts
    Member since:
    Jun 2014

    Posted 09 Jul 2015 Link to this post

    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. T. Tsonev
    Admin
    T. Tsonev avatar
    2772 posts

    Posted 13 Jul 2015 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. arno
    arno avatar
    14 posts
    Member since:
    Jun 2014

    Posted 15 Jul 2015 in reply to T. Tsonev Link to this post

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

    thank you!

Back to Top