Clickable labels

4 posts, 0 answers
  1. Nicholas
    Nicholas avatar
    3 posts
    Member since:
    Aug 2015

    Posted 16 Oct 2015 Link to this post

    I've created a map that adds shapes with a label in the middle similar to this example

     

    http://dojo.telerik.com/eXUL/4

     Around the label I've put a colored rectangle

     

                //Create the Label Rectangle Area
                var draw = kendo.drawing;
                var Rect = kendo.geometry.Rect;
                path = draw.Path.fromRect(new Rect([labelX - 5, labelY - 2], [label.bbox().width() + 10, label.bbox().height() + 4]), {
                    fill: {
                        color: "#307496",
                        opacity: .8
                    }
                });

                //Render the rectangle for the label to sit on
                e.layer.surface.draw(path);

                // Render the label on the layer surface
                e.layer.surface.draw(label);​

      

    Is there a way to add a click function to this rectangle so I can open a window when it is clicked? Similar to how this example works with the click of the triangle

    http://dojo.telerik.com/​

  2. Nicholas
    Nicholas avatar
    3 posts
    Member since:
    Aug 2015

    Posted 16 Oct 2015 Link to this post

    I suspect that it has to do with the multiple layers/surfaces of the map eating the click events, (from the final post here http://www.telerik.com/forums/shapeclick-not-working) but am unsure of how to force everything to draw on one surface of the map
  3. Kendo UI is VS 2017 Ready
  4. T. Tsonev
    Admin
    T. Tsonev avatar
    2772 posts

    Posted 20 Oct 2015 Link to this post

    Hello,

    The approach you use is similar to the one in Add Titles for Map Shapes. Shapes are rendered on the same surface as there are no additional layers on top.

    It is entirely possible to handle the click event, but it has to be attached to the surface on each reset. See this snippet for a sample implementation.

    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!
     
  5. Nicholas
    Nicholas avatar
    3 posts
    Member since:
    Aug 2015

    Posted 20 Oct 2015 Link to this post

    Ah that makes sense. I think I should be able to get it going now. Thanks for the help
Back to Top
Kendo UI is VS 2017 Ready