Search code examples
javascriptzoomingmapquest

MAPQuest Disabling DoubleClick Behaviour


I am working with existing MapQuest maps and I have to implement the functionality that I have to restrict user to double click and zoom the map, from the API documentation I can see options only to disable but there is no code snippet.

window.map = new MQA.TileMap(document.getElementById('map'), 2, null, 'map');

this was previous implementation, I have edited and added option below and its not working,

window.map = new MQA.TileMap(document.getElementById('map'), 2, null, 'map', {zoomOnDoubleClick: false});

below lines I have added, ,{zoomOnDoubleClick: false}``

here is the API guide link API Guide LINK


Solution

  • Create an options object, set the values you want, then pass that in

    var options = {
      elt: document.getElementById('map'),       // ID of map element on page
      zoom: 10,                                  // initial zoom level of the map
      latLng: { lat: 39.7439, lng: -105.0200 },  // center of map in latitude/longitude
      mtype: 'map',                              // map type (map, sat, hyb); defaults to map
      bestFitMargin: 0,                          // margin offset from map viewport when applying a bestfit on shapes
      zoomOnDoubleClick: false                    // disable map from zooming in when double-clicking
    };
    
    // construct an instance of MQA.TileMap with the options object
    window.map = new MQA.TileMap(options);