POST
|
I found the problem…when POSTing requests the GeoEnrichment service is much more picky about the incoming data types, previously study areas was sent as just an object, what I had missed and what is glossed over in the documentation is that studyAreas HAS to be an array of objects not just a single object. But the error message says nothing that would tell you that I just happened to stumble upon the answer almost by accident.
var mp = evt.graphic.geometry;
delete mp.type;
delete mp._partwise;
delete mp._ring;
delete mp._extent;
var studyAreas = {
geometry: mp
}
var saArray = [studyAreas];
var sa = JSON.stringify(saArray);
var dem = new Demographics;
var cats = dem.categories;
var av = '[';
for (l = 0; l < cats.length; l++) {
var curCat = dem[cats ]
for (m = 0; m < curCat.length; m++) {
av += curCat .varName;
av += ',';
}
}
av = av.substr(0, av.length - 1);
av += ']';
xhr.post('/proxy/proxy.ashx?http://geoenrich.arcgis.com/arcgis/rest/services/World/GeoenrichmentServer/Geoenrichment/enrich', {
data: {
studyAreas: sa,
analysisVariables: av,
forStorage: false,
f: 'json'
}
});
... View more
10-01-2014
11:27 AM
|
0
|
0
|
476
|
POST
|
I've been working on an app for a presentation and we are using ArcGIS Online to geoenrich Canadian Census Dissemination Areas upon the users click. The only catch here is that some of the polygons are causing the request URLs to exceed the 2048 character limit in URLs. We are using the ESRI Proxy.ashx that you can get from GitHub and so i switched from a get request to a post request only the Post request doesn't seem to recognizes the variables being passed in the form data. This first link is the request in Raw Format as captured by fiddler http://imgur.com/xlWfh6F The second link is the same request in WebForm view http://imgur.com/3fPoHlL This is the code i'm using to make the request to the proxy server, the proxy adds the token, after it gets the information from our ArcGIS Online account
var studyAreas = {
/* areaType: "RingBuffer",
bufferUnits: "esriKilometers",
bufferRadii: [2],*/
geometry: evt.graphic.geometry
}
var sa = JSON.stringify(studyAreas);
var dem = new Demographics;
var cats = dem.categories;
var av = '[';
for (l = 0; l < cats.length; l++) {
var curCat = dem[cats ]
for (m = 0; m < curCat.length; m++) {
av += curCat .varName;
av += ',';
}
}
av = av.substr(0, av.length - 1);
av += ']';
request.post('/proxy/proxy.ashx?http://geoenrich.arcgis.com/arcgis/rest/services/World/GeoenrichmentServer/Geoenrichment/enrich', {
data: {
StudyAreas: sa,
analysisVariables: av,
forStorage: false,
f: 'json'
}
});
... View more
09-30-2014
02:29 PM
|
0
|
1
|
4057
|
POST
|
I'm trying to access the GeoEnrichment Services, so i was reading the documentation and thought i would test out the sample URLs. The only thing is that i get a service directory is disabled using the URL below i've left off my token for the purposes of this post. I'm just wondering if the URL in the documentation is incorrect or if there could be another reason I can not seem to access this service. https://geoenrich.arcgis.com/arcgis/rest/services/World/geoenrichmentserver/GeoEnrichment/enrich?studyareas=[{%22geometry%22:{%22x%22:-117.1956,%22y%22:34.0572}}]&token= ArcGIS REST Framework Home Error: Services Directory has been disabled. Code: 403
... View more
06-26-2014
11:02 AM
|
0
|
4
|
5600
|
POST
|
Yes it is a dropdown, that contians the "nicknames" for the various sites in the area. Ok will have to check this out.
... View more
06-17-2014
01:38 PM
|
0
|
0
|
468
|
POST
|
I'm afraid i don't see what's wrong with the definition expression. As for the scope issues, yes that was not my preferred way, and the original code looked quite different but this is what happens when i got frustrated iw as trying anything to make it work. and the null parameter is where the heart of this problem lies. I'm not sure how it can be null when the point is being returned to the layer.
... View more
06-17-2014
11:46 AM
|
0
|
0
|
468
|
POST
|
So i've been learning the Javascript API and i've been building a custom page based on several samples. What i'm finding is that I'm obviously not understanding a concept here and it's causing me some problems. The following is a code snip from the page i'm building the entire source can be found at a link at the bottom posted to paste bin. var map;
var currPoint;
require(["esri/map",
"esri/arcgis/utils",
"esri/dijit/Legend",
"esri/graphic",
"esri/symbols/SimpleLineSymbol",
"esri/symbols/SimpleMarkerSymbol",
"esri/renderers/SimpleRenderer",
"esri/symbols/SimpleFillSymbol",
"esri/Color",
"esri/layers/FeatureLayer",
"esri/geometry/Circle",
"esri/layers/OpenStreetMapLayer",
"esri/request",
"esri/tasks/GeometryService",
"dojo/dom",
"dojo/parser",
"dojo/promise/all",
"dojo/_base/array",
"dijit/form/HorizontalSlider",
"dijit/form/HorizontalRule",
"dijit/form/HorizontalRuleLabels",
"dijit/form/TextBox", // this we only include to make an example with TextBox
"dojo/dom-construct",
"dojo/on",
"esri/config",
"dojo/domReady!"], function (Map, arcgisUtils, Legend, Graphic, SimpleLineSymbol, SimpleMarkerSymbol, SimleRenderer,
SimpleFillSymbol, Color, FeatureLayer, Circle, OpenStreetMapLayer, esriRequest, GeometryService,
dom, parser, all,array, HorizontalSlider, HorizontalRule,
HorizontalRuleLabels, TextBox, domConstruct, on, esriConfig) {
var geometryService,baseGraphics;
//esriConfig.defaults.io.corsEnabledServers.push("services3.arcgis.com");
//esriConfig.defaults.io.proxyUrl = "/proxy";
//esriConfig.defaults.io.alwaysUseProxy = false;
map = new esri.Map("mapDiv", {
center: [-114.0288, 51.0669],
zoom: 10
});
var osmLayer = new OpenStreetMapLayer({
id:"osmLayer",
visible:true
});
geometryService = new GeometryService("http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/Geometry/GeometryServer");
var legend = new Legend({
map: map,
layerInfos: (arcgisUtils.getLegendLayers(map))
}, "legendDiv");
legend.startup();
parser.parse();
var rulesNode = domConstruct.create("div", {}, dom.byId("slider"), "first");
var sliderRules = new HorizontalRule({
container: "topDecoration",
count: 6,
style: "width: 5px;"
}, rulesNode);
// Create the labels
var labelsNode = domConstruct.create("div", {}, dom.byId("slider"), "first");
var sliderLabels = new HorizontalRuleLabels({
container: "topDecoration",
labelStyle: "font-style: italic; font-size: 0.75em",
count: 6,
labels: [5, 10, 15, 20, 25, 30]
}, labelsNode);
var slider = new HorizontalSlider({
name: "slider",
value: 5,
minimum: 5,
maximum: 30,
intermediateChanges: true,
discreteValues: 6,
style: "width:300px;",
onChange: function (value) {
dom.byId("sliderValue").value = value;
buildMap();
}
}, "slider");
var siteValue = dom.byId('drpSite').value;
var drpSite = dom.byId("drpSite");
on(drpSite, "change", function (e) {
siteValue = dom.byId('drpSite').value;
buildMap();
});
//alert(value);
var sites = new FeatureLayer("http://services.arcgis.com/sG0VAg8cwgcmMUkE/ArcGIS/rest/services/CalgarySites/FeatureServer/0", {
mode: FeatureLayer.MODE_ONDEMAND,
id: "CalgarySites",
name: "Calgary Sites",
outFields: ["*"]
});
var dt = new FeatureLayer("http://services.arcgis.com/sG0VAg8cwgcmMUkE/ArcGIS/rest/services/CalgarySites%20Drive%20Time%20Final/FeatureServer/0", {
mode: FeatureLayer.MODE_ONDEMAND,
id: "DriveTime",
name: "Drive Times",
});
sites.setDefinitionExpression("NICKNAME='" + siteValue + "'");
map.addLayer(osmLayer);
map.addLayer(dt);
map.addLayer(sites);
sites.on("update-end", function (evt) {
currPoint = new Graphic(evt.target.graphics[0].toJson());
dt.setDefinitionExpression("NICKNAME='" + siteValue + "' and ToBreak=" + sliderValue.value);
});
dt.on("update-end", function (evt) {
var promises = new all({
poilist : executeLocalSearch(currPoint)
}).then(updateGIS);
});
sliderRules.startup();
sliderLabels.startup();
function buildMap() {
sites.setDefinitionExpression("NICKNAME='" + siteValue + "'");
} The error I'm getting is the one listed here. TypeError: Unable to draw graphic (null): evt.target.graphics[0] is undefined currPoint = new Graphic(evt.target.graphics[0].toJson()); my assumption was that when i first getting the error it had to do with the asynchronous nature of the code so i switched to using the update-end on the point layer (sites) figuring that once the update-end fired i should have a graphic with a point. However, the error above seems to imply differently. Any suggestions or help is much appreciated. full code available here. http://pastebin.com/HLhccRkp
... View more
06-17-2014
09:45 AM
|
0
|
5
|
1063
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|