none
How to set Zoom level bigger than Bounding Box/LocationRect RRS feed

  • Question

  • I'd like to set the zoom level of my map bigger than the bounding box.  The following simply sets it to the bounding box zoom:

    Microsoft.Maps.loadModule('Microsoft.Maps.GeoJson', function () {
            var featureCollection = Microsoft.Maps.GeoJson.read(geoData, { polygonOptions: { fillColor: 'rgba(0, 255, 255, 0.3)' } });            
            map.entities.push(featureCollection);
    
            //reset map view
            var rect = Microsoft.Maps.LocationRect.fromShapes(featureCollection);       
            map.setView({ bounds: rect, zoom: 15 });
    });

    Appreciate any help.


    Marilyn Gambone

    Monday, April 22, 2019 1:13 PM

Answers

  • Boundingbox and zoom can't be used together. What you can do is use the boundingbox with the padding option. The padding option adds a pixel buffer around the boundingbox to account for things like the pixel size of a pushpin icon. This will often result in the map being zoomed out.
    • Proposed as answer by Ricky_Brundritt Monday, April 22, 2019 4:13 PM
    • Marked as answer by deskcheck1 Monday, April 22, 2019 5:01 PM
    Monday, April 22, 2019 4:12 PM

All replies

  • Boundingbox and zoom can't be used together. What you can do is use the boundingbox with the padding option. The padding option adds a pixel buffer around the boundingbox to account for things like the pixel size of a pushpin icon. This will often result in the map being zoomed out.
    • Proposed as answer by Ricky_Brundritt Monday, April 22, 2019 4:13 PM
    • Marked as answer by deskcheck1 Monday, April 22, 2019 5:01 PM
    Monday, April 22, 2019 4:12 PM
  • Hi,

    Is the padding option still available for Bing Maps v8?  I've read one comment where it's no longer available for v8.  I tried this but it has no effect:

    map.setView({bounds: rect, padding: 100});


    Marilyn Gambone


    • Edited by deskcheck1 Monday, April 22, 2019 4:58 PM
    Monday, April 22, 2019 4:56 PM