Conditional show context menu based on zoom level

2 posts, 0 answers
  1. Jon
    Jon avatar
    539 posts
    Member since:
    Apr 2004

    Posted 19 Jun 2012 Link to this post

    How can I conditional show/enable a context menu when the zoom level is a certain value.
    I'd like to add a context menu to a pushpin when the pushpin is in view and zoomlevel = 15
    thanks again
  2. Andrey
    Andrey avatar
    1681 posts

    Posted 22 Jun 2012 Link to this post

    Hi Jon,

    I think you just can handle the RadMap.MouseRightButtonUp event. When the event occurs then you can check the zoom level and the pushpin which has been clicked. And when the zoom level does not satisfy a condition then you can mark event as handled using the Handled property of event arguments. It prevents showing of a context menu.
    The sample code is below.
    <telerik:RadMap x:Name="RadMap1" ZoomLevel="14" Center="40,-100" MouseRightButtonUp="MapMouseRightButtonUp">
                <telerik:RadMenuItem Header="Menu Item 1" />
                <telerik:RadMenuItem Header="Menu Item 2" />
                <telerik:RadMenuItem Header="Menu Item 3" />
            <telerik:OpenStreetMapProvider />
        <telerik:InformationLayer x:Name="InformationLayer">
            <telerik:Pushpin telerik:MapLayer.Location="40,-100" />

    private Pushpin clickedPushpin;
    private void MapMouseRightButtonUp(object sender, MouseButtonEventArgs e)
        if (this.RadMap1.ZoomLevel == 15)
            Location location = Location.GetCoordinates(this.RadMap1, e.GetPosition(this.RadMap1));
            IEnumerable<object> list = this.InformationLayer.GetItemsInLocation(location);
            foreach (object item in list)
                Pushpin pushpin = item as Pushpin;
                if (pushpin != null)
                    this.clickedPushpin = pushpin;
        e.Handled = true;

    All the best,
    Andrey Murzov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. DevCraft R3 2016 release webinar banner
Back to Top