|
POST
|
The getUniqueValueInfo function of the UniqueValueRenderer takes a graphic, examines its attributes, and returns an info object with the symbol. I've copied that same function and updated it to instead return the index it creates from the graphic's attributes. If you could get a look at these indexes, this information should tell you what values you need to specify when setting up your renderer. I haven't tested this, but here it is: var featureLayer = map.getLayer("my_layer_id");
var renderer = featureLayer.renderer;
var graphics = featureLayer.graphics;
renderer.getUniqueValueInfo2 = function(a) {
var b = this.attributeField, d = a.attributes, e, f;
this._multiple ? (a = this.attributeField2, e = this.attributeField3, f = [], b && f.push(d),
a && f.push(d), e && f.push(d ), b = f.join(this.fieldDelimiter || "")) : b = c.isFunction(b) ? b(a) : d;
return b;
};
for (var x = 0; x < graphics.length; x++)
console.info(x.toString() + ": [" + renderer.getUniqueValueInfo2(graphics ) + "]");
... View more
08-06-2015
10:34 AM
|
0
|
0
|
1635
|
|
POST
|
I'm not sure exactly what's going on, because I have an app that uses esriRequest over SSL and it works ok. I do have two ideas though: Assuming you have IE 11, you can go to the developer tools (F12), go to the network tab, and do a network trace. You can examine the requests and responses, and maybe compare what they look like when going directly versus going through esriRequest. Pretty much all the other browsers, such as Chrome also have this same capability, but I'm most familiar with IE. Also, I don't access the ArcGIS Server directly (through ports 6080 and 6443) - I use the web adaptor for IIS instead. If you're able, try installing the web adaptor and then take the port numbers out of your urls. It's a long shot, but it may be that the different port numbers are causing your browser to think that you're making cross-domain requests.
... View more
07-24-2015
10:54 AM
|
1
|
1
|
3269
|
|
POST
|
Have you configured your ArcGIS Server instance to be accessed over both http and https? I think the admin console where you do this is at http://server:6080/arcgis/admin if so, what happens when you go directly to the url for the print task?
... View more
07-23-2015
03:33 PM
|
1
|
0
|
3269
|
|
POST
|
I created a new website in Visual Studio 2010, then added an HTML page via Add New Item. I pasted your code in there, ran the debugger and the page loads fine. I opened the network tab on the developer tools window (F12) and noticed that when the browser requested http://js.arcgis.com/3.14/ the server replied with a 302 and redirected to http://js.arcgis.com/3.14/init.js Maybe try that full URL as the src for your script tag.
... View more
07-21-2015
10:38 AM
|
0
|
1
|
1555
|
|
POST
|
You're missing an additional "});" at the end. The following is syntactically correct: require(["esri/tasks/AddressCandidate", "dojo/_base/array"], function (AddressCandidate,array) {
on(dom.byId("btnTest"),"click",function() {
array.forEach(addressCandidates, function(candidate) {
if (candidate.score > score && candidate.attributes.Loc_name === document.getElementById("ownerAddress").value) {
stop = candidate;
score = candidate.score;
// Display the score on the console.
console.log(score);
}
});
});
}); I recommend you bookmark this page: The Online Lint - I use it many times per day.
... View more
07-17-2015
10:38 AM
|
3
|
4
|
1734
|
|
POST
|
Set the wkid of your spatial reference to 4326 instead of 102100. Your coordinates are in WGS 84, not Web Mercator.
... View more
07-09-2015
06:44 PM
|
0
|
0
|
822
|
|
POST
|
I'm not...window.dojoConfig.parseOnLoad is explicitly set to false in my application. My Measurement widget gets created programmatically and then added to the DOM tree as a child of another dijit (a subclass of dijit/Dialog that's been hacked to be modeless). Perhaps adding it as a child of another pre-existing dijit already in the tree makes the difference...
... View more
06-26-2015
11:14 AM
|
1
|
0
|
1165
|
|
POST
|
I can't say with absolute certainty, but I know it worked for me (and now for Arjun as well). I think this behavior started in 3.10. I'm supposing it's called automatically and doesn't need to be explicitly called, but I don't see evidence of that in the Measurement module itself...
... View more
06-26-2015
10:54 AM
|
0
|
0
|
1165
|
|
POST
|
I've run into this as well...our map should default to one of several sites, but no amount of fooling with the fitExtent and extent parameters (including shrinking the default extent) produces a sure fit for all of them. More often, the map starts up one level too far in for some, or one level too far out for others. And there's also cases where the map should start up where the user previously left off, and even with the same screen size as before, the map still often starts at the wrong zoom level. It's been giving me fits for awhile, but I've gotten to the bottom of it. The reason this occurs is found in the _coremap module. In the _addLayerHandler function, observe what happens when the map's graphics container is added (when the map loads): if (a === this.graphics) {
...
this._firstLayerId = null;
...
d = this._fixExtent(b, i.fitExtent);
this.extent = d.extent; //THIS LINE CAUSES THE PROBLEM
this.__LOD = d.lod;
this.__setExtent(this.extent, null, null, i.fitExtent);
...
} Notice the call to __setExtent. One of the first things that happens in __setExtent is another call to _fixExtent - with the already-fixed extent. This extra call can result in an expanded extent that causes the map to start up one zoom level out from where it should. The simplest fix is to rewrite the problem line to: this.extent = this.extent || d.extent; If you have a local copy of the API, you can implement this fix on your own, but that can be tricky. You'd have to update init.js, and finding that particular line can be difficult, especially since variable names can be different. There are workarounds though. I've written a function called setDefaultExtentOptions that adjusts your default extent to match the actual extent your map will show, and appends appropriate values to the options parameter (the second parameter) that you pass into the map's constructor. The function and workflow would go like: function setDefaultExtentOptions(defaultExtent, mapContainerID, options) {
var contentBox = domGeom.getContentBox(document.getElementById(mapContainerID));
var extentHeight = defaultExtent.getHeight();
var extentWidth = defaultExtent.getWidth();
var viewHeight, viewWidth;
var lods = options.lods;
var dY, dX;
var center;
var lod;
options.spatialReference = defaultExtent.spatialReference;
options.extent = defaultExtent;
options.fitExtent = true;
for (var x = lods.length - 1; x >= 0; x--) {
lod = lods ;
viewHeight = lod.resolution * contentBox.h;
viewWidth = lod.resolution * contentBox.w;
if ((viewHeight > extentHeight) && (viewWidth > extentWidth)) {
center = defaultExtent.getCenter();
dY = viewHeight * 0.5;
dX = viewWidth * 0.5;
options.extent = new Extent(center.x - dX, center.y - dY, center.x + dX, center.y + dY, defaultExtent.spatialReference);
options.fitExtent = false;
options.scale = lod.scale;
options.zoom = lod.level;
options.center = center;
return;
}
}
}
var defaultExtent = new Extent(minX, minY, maxX, maxY, new SpatialReference(wkid));
var divId = "map"; //set according to your div's ID.
var options = {
//set map options here...MUST INLCUDE VALUE FOR lods
};
setDefaultExtentOptions(defaultExtent, divId, options);
var map = new Map(divId, options); I implemented this workaround before actually figuring the problem out. There are probably better workarounds, but optimally, a workaround wouldn't be necessary. I see the question was initially raised for 2.8, but it's still happening in 3.13, which I'm using.
... View more
06-12-2015
07:09 AM
|
0
|
1
|
1054
|
|
POST
|
I've found that the map's wrapAround180 behavior will fail under certain circumstances where it should not. When instantiating a map with wrapAround180 set to true, and the lods option specified, the map will create an internal TileInfo object based on WGS 84 (4326). However, if you add a tiled layer based on Web Mercator (which all of mine are), the map will make some internal comparisons between the Web Mercator spatial reference and WGS 84 spatial reference definitions, and conclude wrapping is no longer possible. The problem therefore lies with the default TileInfo created by the map, over which the user has no documented control, and which is created whether or not you have any layers based on WGS 84. There is a workaround though. After instantiating your map, create a new TileInfo object based on Web Mercator, and make a couple assignments: var map = new Map("map", options); var tileInfo = new TileInfo({ dpi: 96, height: 256, lods: options.lods, origin: new Point(-20037508.342787, 20037508.342787, new SpatialReference(102100)), spatialReference: new SpatialReference(102100), width: 256 }); map._params.tileInfo = tileInfo; map.__tileInfo = tileInfo; I'm currently using version 3.13.
... View more
06-10-2015
10:51 AM
|
0
|
6
|
5421
|
|
POST
|
A bug in the WMTSLayer constructor prevents any instances of this class from being created. In the constructor, the call to _parseResourceInfo occurs before the _formatDictionary property is instantiated. However, the call to _parseResourceInfo includes a read of the _formatDictionary property, which, being undefined at the time, results in an unhandled exception. Noticed in version 3.13. If you have a locally hosted copy of the API, you can fix this yourself by moving the instantiation of _formatDictionary higher up in the constructor.
... View more
06-08-2015
06:38 AM
|
0
|
7
|
4666
|
|
POST
|
So I noticed I answered a question you didn't ask...I should keep that in mind next time somebody does the same to me. Anyhow, try this, which is also entirely client side. I've attached a copy since this forum software eliminates my extra line breaks. Note that I've tested this against ESRI's Measure widget, and concluded the Measure widget doesn't work properly. I've hand calculated the distance between two points after acquiring their coordinates from the map, and it's quite a bit different from what the Measure tool measures between those points. I tested with data in Web Mercator...not sure if that would make a difference. As such, I think this works properly. It assumes a few things, like a valid polyline with at least one path that has at least 2 points. It returns null if the distance is greater than the path's length, or if the distance is negative. function distanceBetweenPoints(x1, y1, x2, y2) {
return Math.sqrt(Math.pow(x2 - x1, 2) + (Math.pow(y2 - y1, 2)));
}
function getPointAlongLine(polyline, distance, pathIndex) {
if (!pathIndex)
pathIndex = 0;
if (!distance)
distance = 0;
if ((pathIndex >= 0) && (pathIndex < polyline.paths.length)) {
var path = polyline.paths[pathIndex];
var x1, x2, x3, y1, y2, y3;
var travelledDistance = 0;
var pathDistance;
var distanceDiff;
var angle;
if (distance === 0)
return polyline.getPoint(pathIndex, 0);
else if (distance > 0) {
for (var i = 1; i < path.length; i++) {
x1 = path[i-1][0];
y1 = path[i-1][1];
x2 = path[0];
y2 = path[1];
pathDistance = this._distanceBetweenPoints(x1, y1, x2, y2);
travelledDistance += pathDistance;
if (travelledDistance === distance)
return polyline.getPoint(pathIndex, i);
else if (travelledDistance > distance) {
distanceDiff = pathDistance - (travelledDistance - distance);
angle = Math.atan2(y2-y1, x2-x1);
x3 = distanceDiff * Math.cos(angle);
y3 = distanceDiff * Math.sin(angle);
return new Point(x1 + x3, y1 + y3, polyline.spatialReference);
}
}
}
}
return null;
}
... View more
06-05-2015
11:51 AM
|
2
|
2
|
4379
|
|
POST
|
I just realized that included a call to another custom function - distanceTo. Here's the function definition: Point.prototype.distanceTo = function(point) {
return Math.sqrt(Math.pow(this.x - point.x, 2) + (Math.pow(this.y - point.y, 2)));
};
... View more
06-03-2015
11:15 AM
|
0
|
0
|
4379
|
|
POST
|
Based on code I found here: c# - get closest point to a line - Stack Overflow I have implemented the following function, which has been working well. As you can see, it is entirely client-side, and I have assigned the function to the Polyline "type" so I can simply call polyline.getClosestPoint(etc), but you can make it a standalone function like: function getClosestPoint(polyline, point) { //code } ...and changing "this" to "polyline". Polyline.prototype.getClosestPoint = function(point) {
var closestDistance = Number.MAX_VALUE;
var closestPoint = null;
var abapProduct;
var sqMagnitude;
var distance;
var vectorAP;
var vectorAB;
var pointA;
var pointB;
var pointC;
for (var pathIndex = 0; pathIndex < this.paths.length; pathIndex++) {
for (var pointIndex = 1; pointIndex < this.paths[pathIndex].length; pointIndex++) {
pointA = this.getPoint(pathIndex, pointIndex);
pointB = this.getPoint(pathIndex, pointIndex - 1);
vectorAP = [point.x - pointA.x, point.y - pointA.y];
vectorAB = [pointB.x - pointA.x, pointB.y - pointA.y];
sqMagnitude = Math.pow(vectorAB[0], 2) + Math.pow(vectorAB[1], 2);
abapProduct = (vectorAB[0] * vectorAP[0]) + (vectorAB[1] * vectorAP[1]);
distance = abapProduct / sqMagnitude;
if (distance < 0)
pointC = pointA;
else if (distance > 1)
pointC = pointB;
else
pointC = new Point(pointA.x + (vectorAB[0] * distance), pointA.y + (vectorAB[1] * distance), this.spatialReference);
distance = pointC.distanceTo(point);
if (distance < closestDistance) {
closestDistance = distance;
closestPoint = pointC;
}
}
}
return closestPoint;
};
... View more
06-03-2015
10:37 AM
|
1
|
1
|
4379
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 12-09-2025 09:35 AM | |
| 2 | 12-09-2025 09:06 AM | |
| 1 | 11-26-2025 12:29 PM | |
| 3 | 11-26-2025 09:11 AM | |
| 1 | 10-02-2025 01:14 PM |