none
How to disable map dragging RRS feed

  • Question

  • How to disable map dragging ?

    I have seen this :  https://social.msdn.microsoft.com/Forums/en-US/7e58a52d-1a00-4891-90cd-f17ddd6b7848/disable-map-dragging?forum=bingmaps but not work for me.

    this.map = new Microsoft.Maps.Map(document.getElementById(this._mapId), {
                    credentials:    this._key,
                    center:         new Microsoft.Maps.Location(46.6373, 2.3383),
                    zoom:           10,
                    showBreadcrumb: true,
                    showDashboard:  false
    });

    Microsoft.Maps.Events.addHandler(this.map, 'mousemove', function (e) {
    e.handled = true;
    console.log('mousemove');
    });

    'mousemove' is printed but i can always drag the map.

    I use bing maps v8.

    Thanks

    Monday, August 1, 2016 1:22 PM

Answers

  • This is easy to do in Bing Maps V8 as there is a new map option called disablePanning. You can find a list of all the map options in V8 here: https://msdn.microsoft.com/en-us/library/mt712646.aspx

    You can update your code to the following:

    this.map = new Microsoft.Maps.Map(document.getElementById(this._mapId), {
        credentials: this._key,
        center: new Microsoft.Maps.Location(46.6373, 2.3383),
        zoom: 10,
        showBreadcrumb: true,
        showDashboard:  false,
        disablePanning: true
     }); 


    [Blog] [twitter] [LinkedIn]

    Monday, August 1, 2016 4:26 PM