admin管理员组

文章数量:1426626

Title explains it well.

I am using "Bing Maps AJAX Control, Version 7.0". I successfully disabled the mouse wheel from zooming in and out of the map. However, if I am hovering over a marker(pin) on the map, It still is zooming in and out.

Below is the code that I used to disabled the mouse wheel:

Microsoft.Maps.Events.addHandler(map, 'mousewheel', function(e) {
  if(e.targetType == 'map') {
    e.handled = true;
  }
});

Title explains it well.

I am using "Bing Maps AJAX Control, Version 7.0". I successfully disabled the mouse wheel from zooming in and out of the map. However, if I am hovering over a marker(pin) on the map, It still is zooming in and out.

Below is the code that I used to disabled the mouse wheel:

Microsoft.Maps.Events.addHandler(map, 'mousewheel', function(e) {
  if(e.targetType == 'map') {
    e.handled = true;
  }
});
Share Improve this question edited Dec 10, 2013 at 7:38 Kara 6,22616 gold badges53 silver badges58 bronze badges asked Apr 26, 2012 at 21:16 Mike HenkenMike Henken 1801 silver badge8 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 5

The following code worked fine for me:

Microsoft.Maps.Events.addHandler(map, 'mousewheel', function(e) {
    e.handled = true;
    return true;
});

For others that may e across this question that want to know how to pletely disable zooming (i.e. via the scroll wheel or otherwise) in Bing Maps AJAX API v7, here's how:

var options = {
   credentials: 'put-your-credentials-here',
   **disableZooming: true**

}

map = new Microsoft.Maps.Map(document.getElementById('myMap'), options);

The Bing Maps API provides other MapOptions, as documented here.

Regarding @Mike Henken's problem:

However, if I am hovering over a marker(pin) on the map, It still is zooming in and out.

That appears to be a bug in Bing Maps v7 API that has been fixed as of 8/5/2013. I can no longer reproduce that problem.

本文标签: javascriptHow to disable mouse scroll over markers in Bing Maps v7Stack Overflow