none
How to disable the map's scrolling/pan/zooming

    Question

  • Hello,

    I want to show the static map with some pushpins. But it seems that the BingMap control doesn't have a property for suppressing the scroll/pan/zoom behavior.

    In the WPF, it seems that the map control has "SupportedManipulations" property, but in the store apps, the map control doesn't have such property. How can I accomplish this?

    Any suggestions are appreciated.

    Thursday, February 13, 2014 3:38 AM

Answers

  • If you want to display a static map image then use the REST imagery service. This will give you a nice static image without all the overhead of loading an interactive map. http://msdn.microsoft.com/en-us/library/ff701721.aspx

    If you want to disable panning and zooming in the native Bing Maps windows store SDK you can capture map events. One method is to catch the pointer and tap events and mark them as handled. This would disable the all the panning and zooming via a mouse or touch. You would also want to hide the zoom buttons as well. For example:

    MyMap.DoubleTappedOverride += (s, e) =>
    {
        e.Handled = true;
    };
    
    MyMap.PointerPressedOverride += (s, e) =>
    {
        e.Handled = true;
    };
    
    MyMap.TappedOverride += (s, e) =>
    {
        e.Handled = true;
    };

    Another method is to use the view change method and store the center and zoom level you want to lock the map to. When the view change event fires set the map center and zoom to the store values. This will complete disable all navigation of the map. For example:

    var mapCenter = new Location(52, 0);
    var zoom = 15;
    
    MyMap.ViewChanged += (s, e) =>
    {
        MyMap.Center = mapCenter;
        MyMap.ZoomLevel = zoom;
    };


    http://rbrundritt.wordpress.com

    Thursday, February 13, 2014 11:51 AM
    Owner

All replies

  • If you want to display a static map image then use the REST imagery service. This will give you a nice static image without all the overhead of loading an interactive map. http://msdn.microsoft.com/en-us/library/ff701721.aspx

    If you want to disable panning and zooming in the native Bing Maps windows store SDK you can capture map events. One method is to catch the pointer and tap events and mark them as handled. This would disable the all the panning and zooming via a mouse or touch. You would also want to hide the zoom buttons as well. For example:

    MyMap.DoubleTappedOverride += (s, e) =>
    {
        e.Handled = true;
    };
    
    MyMap.PointerPressedOverride += (s, e) =>
    {
        e.Handled = true;
    };
    
    MyMap.TappedOverride += (s, e) =>
    {
        e.Handled = true;
    };

    Another method is to use the view change method and store the center and zoom level you want to lock the map to. When the view change event fires set the map center and zoom to the store values. This will complete disable all navigation of the map. For example:

    var mapCenter = new Location(52, 0);
    var zoom = 15;
    
    MyMap.ViewChanged += (s, e) =>
    {
        MyMap.Center = mapCenter;
        MyMap.ZoomLevel = zoom;
    };


    http://rbrundritt.wordpress.com

    Thursday, February 13, 2014 11:51 AM
    Owner
  • Great! It works well.

    Thank you for your kindly help.

    Thursday, February 13, 2014 11:56 PM
  • Hi, may I ask you one more question?

    Can I bubble up the panning/zooming gesture to the parent control?
    For example, if I use Map control inside the container control, such as ScrollViewer or Hub, the users would expect that the container will scroll/pan/zoom with the gesture on the map control.

    If I use the e.Handled = true, the event will not bubble up.
    Is there any workaround for this?

    Any suggestions are appreciated.

    Friday, February 14, 2014 1:47 AM