|
POST
|
You can probably get around this by appending the token to the query string of your layer's URL. For example, you may have something like: var url = "https://my-server.com/arcgis/rest/services/my-service/MapServer";
var layer = new ArcGISDynamicMapServiceLayer(url); Instead, append the token like so: var url = "https://my-server.com/arcgis/rest/services/my-service/MapServer?token=" + token; This if course assumes your token is stored in a variable called "token". Tokens expire too, so once it does, you'll probably see the identity popup again, unless you write code to manually acquire a new token.
... View more
03-04-2015
10:57 AM
|
1
|
3
|
1258
|
|
POST
|
I had to look into this further because it also wasn't working properly with my own FeatureLayers. I've found that FeatureLayers have a _task property which is an instance of QueryTask. This _task property is created when the FeatureLayer is initialized, and its URL never appears to get updated after that (as far as I can tell). Anyhow, I've revised the function to below (and it appears to be working properly). Nothing like building an airplane while you're flying it... function setLayerTokenProperties(layer, token, expires) {
if ((layer) && (token)) {
layer.url = addTokenToURL(token, layer.url);
layer._url = urlUtils.urlToObject(layer.url);
layer._params.token = token;
if (layer.credential) {
layer.credential.token = token;
layer.credential.expires = expires;
}
if ((layer.declaredClass == "esri.layers.FeatureLayer") && (layer._task)) {
layer._task.url = layer.url;
layer._task._url = urlUtils.urlToObject(layer.url);
}
}
}
... View more
02-18-2015
10:33 AM
|
0
|
0
|
1566
|
|
POST
|
My code there was incorrect...it should be "layer.credential" (singular), not "layer.credentials" (plural). That's what I get for posting untested code... Yes, what I originally posted works with instances of ArcGISDynamicMapServiceLayer, ArcGISTiledMapServiceLayer, ArcGISImageServiceLayer, and FeatureLayer.
... View more
02-13-2015
11:36 AM
|
0
|
1
|
1566
|
|
POST
|
Once such possibility that might be causing this not to work for you is if your layers use the credential property (which mine do not). If so, updating the setTokenLayerProperties method like below may make the difference (although I haven't tested this): function setLayerTokenProperties(layer, token, expires) {
if ((layer) && (token)) {
layer.url = addTokenToURL(token, layer.url);
layer._url = urlUtils.urlToObject(layer.url);
layer._params.token = token;
if (layer.credentials) {
layer.credentials.token = token;
layer.credentials.expires = expires;
}
}
}
... View more
02-13-2015
10:21 AM
|
0
|
1
|
1566
|
|
POST
|
Unfortunately I cannot explain why it works for me and not you - my map wouldn't even load if it didn't. I'm using IE 11, but don't think that's the culprit. The _url and _params properties are not documented. I found them by going into the source code for the layer classes (Layer, DynamicMapServiceLayer, ArcGISDynamicMapServiceLayer, etc). It's unorthodox, but I have to thoroughly test between each new version of the API anyways...
... View more
02-12-2015
03:39 PM
|
0
|
0
|
1566
|
|
POST
|
Interesting you should ask since I was working on this yesterday. Below you will find the essentials of my solution, and it appears to be working well with 3.12, although its elegance is debatable. Note that "urlUtils" is esri/urlUtils - you'll have to figure out how best to work that module into your solution. function setLayerTokenProperties(layer, token) {
if ((layer) && (token)) {
layer.url = addTokenToURL(token, layer.url);
layer._url = urlUtils.urlToObject(layer.url);
layer._params.token = token;
}
}
function addTokenToURL(token, url) {
if ((url) && (token)) {
var sIndex = url.indexOf("token=");
if (sIndex > 0) {
var eIndex = url.indexOf("&", sIndex + 1);
if (eIndex > sIndex)
return url.substring(0, sIndex) + "token=" + token + url.substr(eIndex);
else
return url.substring(0, sIndex) + "token=" + token;
} else if (url.indexOf("?") > 0)
return url + "&token=" + token;
else
return url + "?token=" + token;
} else
return url;
}
... View more
02-12-2015
10:40 AM
|
0
|
5
|
1566
|
|
POST
|
I agree that the code Robert posted will work for the stated purpose. My invalid assumption was based on the fact that the user was drawing a circle. I find it strange for a user to draw a circle just so it can be discarded - it seems you're really just after the center point so that you can build a circle of fixed size around it. Unless your goal is to deceive or confuse the user, it might be better just to have them click the center point instead: $('#circle').click(function () {
clearPreviousSearch();
map.disableMapNavigation();
$('#run').fadeOut();
buttonclickvalue = 'circle';
drawToolbar.activate(esri.toolbars.Draw.POINT);
});
function addSearchGraphic(evt) {
var circle = new Circle({
center: evt.geometry,
geodesic: true,
radius: 10,
radiusUnit: esri.units.KILOMETERS
});
//now do whatever with the circle
}
... View more
02-09-2015
10:56 AM
|
1
|
0
|
1652
|
|
POST
|
Robert - Your code would produce a circle of 100 mile radius even if the user drew a circle with a radius less than that, which I don't think is what's intended. Perhaps something like the following would be more appropriate: function addSearchGraphic(evt) {
var maxCircle = new Circle({
center: evt.geometry.getCentroid(),
geodesic: true,
radius: 100,
radiusUnit: units.MILES
});
var maxCircleExtent = maxCircle.getExtent();
var maxCircleArea = maxCircleExtent.getWidth() * maxCircleExtent.getHeight();
var drawnCircleExtent = evt.geometry.getExtent();
var drawnCircleArea = drawnCircleExtent.getWidth() * drawnCircleExtent.getHeight();
var resultCircle = ((drawnCircleArea > maxCircleArea) ? maxCircle : evt.geometry);
//set the symbol to something meaningful
var symbol = null;
//assume reference to map is valid
map.graphics.add(new Graphic(resultCircle, symbol));
}
... View more
02-06-2015
10:49 AM
|
0
|
4
|
1652
|
|
POST
|
I've had similar problems, and the solution I've come up with is to revise the _setPosition method of the Popup "class". It ensures the popup always opens "towards" the center of the map (i.e. where it will have the most space). The full popup is guaranteed to be visible if (1) the popup width inlcuding the pointer is less than half the width of the map and (2) the popup height inlcuding the pointer is less than half the height of the map. The trick is to execute the code below before any popups are instantiated. However, if the only popup in the application is the map's, you could replace Popup.prototype._setPosition = function(screenPoint) { with map.infoWindow._setPosition = function(screenPoint) { (assuming "map" is a reference to your map object). As I'm preparing this post, the code below looks kind of garbled, and not nicely formatted like in the source file, so hopefully it comes out ok. If not, I've also attached the text file containing it. require(["dojo/dom-geometry", "dojo/dom-style", "esri/kernel", "esri/dijit/Popup"], function(domGeom, domStyle, esriNS, Popup) { /** modified to open popup with best possible placement (towards center of screen) **/
Popup.prototype._setPosition = function(screenPoint) {
domStyle.set(this.domNode, {
left: screenPoint.x + "px",
top: screenPoint.y + "px",
right: null,
bottom: null
}); var mapBox = domGeom.position(this.map.container, true);
var horizontalPosition = "";
var verticalPosition = ""; if (screenPoint.x < (mapBox.w * 0.33))
horizontalPosition = "Left";
else if (screenPoint.x > (mapBox.w * 0.67))
horizontalPosition = "Right"; if (screenPoint.y < (mapBox.h * 0.33))
verticalPosition = "top";
else if (screenPoint.y > (mapBox.h * 0.67))
verticalPosition = "bottom";
else if (horizontalPosition == "") {
horizontalPosition = ((screenPoint.x < (mapBox.w * 0.5)) ? "Left" : "Right");
/*verticalPosition = ((screenPoint.y < (mapBox.h * 0.5)) ? "top" : "bottom");*/
} var anchorText = verticalPosition + horizontalPosition;
var offsetX = ((this.offsetX) ? this.offsetX : 0);
var offsetY = ((this.offsetY) ? this.offsetY : 0);
var positionerHeight = 0;
var positionerWidth = 0; switch (anchorText) {
case "top":
case "bottom":
positionerHeight = 14;
break; case "Left":
case "Right":
positionerWidth = 13;
break; default:
var esriVersion = esriNS.version.toString().split(".");
esriVersion[0] = parseInt(esriVersion[0], 10);
esriVersion[1] = parseInt(esriVersion[1], 10); if ((esriVersion[0] > 3) || ((esriVersion[0] == 3) && (esriVersion[1] >= 8))) {
positionerHeight = 14;
positionerWidth = -16;
} else
positionerHeight = 45; break;
} var positionerBox = domGeom.getContentBox(this._positioner);
var positionerStyle = {
left: null,
right: null,
top: null,
bottom: null
}; if (horizontalPosition == "")
positionerStyle.left = (positionerBox.w * -0.5) + "px";
else
positionerStyle[horizontalPosition.toLowerCase()] = (positionerWidth + offsetX) + "px"; if (verticalPosition == "")
positionerStyle.top = (positionerBox.h * -0.5) + "px";
else
positionerStyle[verticalPosition] = (positionerHeight + offsetY) + "px"; domStyle.set(this._positioner, positionerStyle);
this._showPointer(anchorText);
};
});
... View more
01-29-2015
11:03 AM
|
2
|
4
|
748
|
|
POST
|
The only problem I see here is in the line: query.where = "PhoneNumber = " +"'"+number+"'"; The problem is that I don't see where the variable "number" is declared or assigned a value. Unless you've declared and assigned the value elsewhere, this could be the main issue. Perhaps the following might make a difference: query.where = "PhoneNumber = '" + dom.byId("number").value + "'";
... View more
01-14-2015
10:55 AM
|
1
|
1
|
1132
|
|
POST
|
I've found the 3.12 measurement widget gives incorrect results under certain circumstances. This can be reproduced on the Measurement sample hosted by ESRI at: http://developers.arcgis.com/javascript/samples/widget_measurement/ To reproduce: 1) Select the distance tool. 2) Select any units except Miles. 3) Draw and finish a polyline with the measure tool. The number of vertices is insignificant. After drawing, the measurement is correct. 4) Change the units to something else. The value is updated, but incorrect. If you're using a locally hosted version of the API, here are the instructions that [I believe] fix the problem: 1) open esri/dijit/Measurement.js with Notepad or other text editing program 2) Search (ctrl-f) for the following text (it only occurs once in the file): this.result=this._outputResult 3) Keep the function call, but remove the assignment. For example, change it to: /*this.result=*/this._outputResult 4) Save the file
... View more
01-09-2015
02:00 PM
|
0
|
2
|
4747
|
|
POST
|
This is definitely a bug in Esri's code.
/**
* Creates an array of LegendLayers of all layers currently visible in the map.
* @param {esri.Map} map
* @returns {esri.tasks.LegendLayer[]}
*/
function getLegendLayersFromMap(map) {
var layer, legendLayer, output = [];
for (var i = 0, l = map.layerIds.length; i < l; i += 1) {
layer = map.getLayer(map.layerIds);
if (layer.visible && layer.visibleAtMapScale) {
legendLayer = new LegendLayer();
legendLayer.layerId = layer.id;
if (layer.visibleLayers) {
legendLayer.subLayerIds = layer.visibleLayers;
}
output.push(legendLayer);
}
}
// Return null if the output array has no elements.
return output.length > 0 ? output : null;
}
// Sample call
var printParameters = new PrintParameters();
printParameters.map = map;
var template = new PrintTemplate();
template.format = "PDF";
// printUI is a custom class in my app that creates and manages the HTML UI for a print task form.
template.layout = printUI.getSelectedTempalteName();
template.layoutOptions = {
authorText:printUI.form.querySelector("input[name=author]").value,
titleText: printUI.form.querySelector("input[name=title]").value,
legendLayers: getLegendLayersFromMap(map)
};
printParameters.template = template;
printTask.execute(printParameters);
Agreed (somewhat)...a look at _createOperationalLayers in PrintTask.js of v3.9 of the JavaScript API shows a switch for which there is no case for "esri.layers.ArcGISTiledMapService". I think it's only a bug, though, if omitting this type of layer was unintentional. However, I can't think of any good reason as to why they would omit it. Whatever the case, their own documentation is, at minimum, misleading.
... View more
08-12-2014
01:44 PM
|
0
|
1
|
2319
|
|
POST
|
Answer to both is no. For example, support for Oracle User defined types is new in the Oracle 11 Client's Oracle Data Provider for .NET. I've used this functionality for extracting SDO_GEOMETRY information from our Oracle 10 database, and it works fine.
... View more
06-29-2011
05:18 AM
|
0
|
0
|
879
|
|
POST
|
Before answering these questions, I just have to say I haven't tried using any of the configurations you've mentioned, but would be fairly confident it would work. We're currently using Oracle database 10.2.0.4, but I have both Oracle 10 and Oracle 11 clients on my machine, and I can use either version of the client and still get the same results for the things we do. For question number 1, yes, but only because you use the word "should". For question number 2, yes the 11 client has new features, but you could probably still get by with the 10 client. For question number 3, probably... Nothing can substitute for your own testing, since you know best what you and your company do with this software. You can probably find documentation from Oracle about new features for each release, etc, which would be worth your while to look into.
... View more
06-28-2011
09:53 AM
|
0
|
0
|
879
|
|
POST
|
Note that what you have in the service parameter is based upon the version of Oracle Client you have on the client machine, not the database version on the server. So if you upgrade the database to 11, but leave the 10 client on your client machines, you could still use sde:oracle10g. You would only have to change if you remove the Oracle 10 client from your client machines.
... View more
06-28-2011
06:12 AM
|
0
|
0
|
879
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | Tuesday | |
| 1 | Tuesday | |
| 1 | 2 weeks ago | |
| 3 | 2 weeks ago | |
| 1 | 10-02-2025 01:14 PM |