tmcgee/cmv-widgets

Zoom to Feature zooms in too close to feature

cmccullough2 opened this issue · 2 comments

I need to zoom to a feature at 1:72,224 scale. how can I update my code to make this happen. i see two locations where code could be altered. i do not need to change the size of the buffer graphic.
postCreate: function () {
this.inherited(arguments);

        if (!this.spatialReference) {
            this.spatialReference = this.map.spatialReference.wkid;
        }
        if (!this.pointExtentSize) {
            if (this.spatialReference === 4326) { // special case for geographic lat/lng
                this.pointExtentSize = 0.0001;
            } else {
                this.pointExtentSize = 250; // could be feet or meters
            }
        }

zoomToExtent: function (extent) {
this.map.setExtent(extent.expand(1.5));
console.log(extent);
},

@cmccullough2 Assuming your basemap uses the Web Mercator spatial reference, you can simply set the map's zoom level to 13 which has a scale of 72,224

zoomToExtent: function (extent) {
    this.map.setExtent(extent.expand(1.5));
    this.map.setZoom(13);
},

the first line will center the map on the feature before zooming the map in/out to level 13;

Beautiful! worked like a charm. Thanks