AnsweredAssumed Answered

using envelope center and envelope angle to compute extent.

Question asked by dolot on Mar 20, 2017
Latest reply on Mar 21, 2017 by dolot

Got a problem.

I have an mvc app where I need to display a map zoomed to the extent of a number of features.  So what I did was union all the features together using DbGeometry on the server side, and then passed the envelope object to the client as a WKT and use that to compute the map extent as shown below: 


require(["dojo/parser", "dijit/layout/TabContainer", "dijit/layout/ContentPane"]);


var mapArgs = {

sliderStyle: "small",

sliderPosition: "top-right",

basemap: "topo"


//get the default extent, if specified

var parser = new geometryWktParser();

var defaultBounds = parser.loadPolygonGeographic('@Model.qdArcsExtent');

mapArgs.extent = defaultBounds.getExtent();


//build the map

require(["esri/map", "dojo/domReady!"], function (Map) {

map2 = new Map("qdMap", mapArgs);


Well, this doesn't seem to work real well. The map extent is either off center from where it should be or not big enough to display all the features - or both.  Sometimes it isn't off by much, but other times it's wildly off.


So I tried using DbGeography instead of DbGeometry, but DbGeography doesn't have any kind of envelope or extent.  So then I tried SqlGeography.  SqlGeography has EnvelopeCenter and EnvelopeAngle.  How would I use these to compute the map extent on the client side - is it even possible?