using envelope center and envelope angle to compute extent.

963
4
03-20-2017 08:40 AM
DaveSouthern
New Contributor II

Got a problem.

I have an asp.net 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?

0 Kudos
4 Replies
ThomasSolow
Occasional Contributor III

There's no reason you can't do this in the client.

I would check out esri/graphicsUtils | API Reference | ArcGIS API for JavaScript 3.20 

The graphicsExtent method will take an array of Graphics (features) and return an extent.  What you need to do is find out where your graphics are getting stored in the client.

DaveSouthern
New Contributor II

So I'm guessing from what you've said that there's no way to use the envelope point and angle on the client side to set the extent?

0 Kudos
ThomasSolow
Occasional Contributor III

As far as I know, there isn't any way to generate a polygon or extent from a point and an angle.

0 Kudos
DaveSouthern
New Contributor II

OK.  Looks like I'll have to rethink this and consult with the senior dev on it.  This isn't really my project - I'm just helping out with it.  Not sure we have the necessary data relationships in the client side data model to perform the querying that we need to do.  Have to see.

In any case, thanks for your advice on this - at least I know what I'm doing is a dead end. 

0 Kudos