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

Clickable labels

3 Answers 147 Views
Map
This is a migrated thread and some comments may be shown as answers.
Nicholas
Top achievements
Rank 1
Nicholas asked on 16 Oct 2015, 02:18 PM

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/​

3 Answers, 1 is accepted

Sort by
0
Nicholas
Top achievements
Rank 1
answered on 16 Oct 2015, 06:25 PM
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
0
T. Tsonev
Telerik team
answered on 20 Oct 2015, 03:44 PM
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!
 
0
Nicholas
Top achievements
Rank 1
answered on 20 Oct 2015, 05:27 PM
Ah that makes sense. I think I should be able to get it going now. Thanks for the help
Tags
Map
Asked by
Nicholas
Top achievements
Rank 1
Answers by
Nicholas
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or