|
POST
|
I'm using ArcGIS Server 10.11, .NET SOE. I'm trying to convert a List<List<int>> to a Json result in our .NET SOE and it keeps throwing the following error.
{
"error": {
"code": 500,
"message": "Object cannot be stored in an array of this type."
}
}
Here is the code I am using.
List<List<int>> results = UtilHelper.RunMethod();
JsonObject json = new JsonObject();
JsonObject[][] jsonResults = new JsonObject[results.Count][];
for (int j = 0; j < results.Count; j++)
{
var list = results.ElementAt(j);
JsonObject[] obj = new JsonObject[list.Count];
for (var k = 0; k < list.Count; k++)
{
obj.SetValue(list.ElementAt(k), k);
}
jsonResults.SetValue(obj, j);
}
json.AddArray("results", jsonResults);
return Encoding.UTF8.GetBytes(json.ToJson());
The result would look something like
{
"results":[
[1,2,3],
[11,22,33],
[], // an array could be empty
[99,100,101]
]
}
Eventually, we're going to refactor this out to build JsonObject[] using that helper method, but for now, I just need to convert this so we don't have to update much more on the client side other than the URL endpoints. I'm a little stumped on this one. If I parse the results using StringBuilder, they come out ok, but then they are not JSON and I can't parse them on the client side. I can't find much info in the docs for JsonObject and it looks like there is a JSONArray, but I'm unsure how to use that or even if I should. Any insight would be greatly appreciated, thanks!
... View more
10-24-2013
02:31 PM
|
0
|
2
|
1251
|
|
POST
|
The LocateButton takes standard Geolocation API settings, such as enableHighAccuracy https://developers.arcgis.com/en/javascript/jsapi/locatebutton-amd.html#geolocationoptions This will use a GPS if available, if not, it does some fallbacks to other methods, but that is handled by the API. Geolocation API specs http://www.w3.org/TR/geolocation-API/#position-options The widget actually has a github page showing all the options https://github.com/driskull/arcgis-dijit-locate-button-js I'm not familiar with the setup of the Basic Viewer, but you should be able to get the widget working with it. Do you have some code you used to try and add it to the viewer? Make sure the viewer is referencing version 3.7 of the AGS JS API.
... View more
10-23-2013
10:55 AM
|
0
|
0
|
2825
|
|
POST
|
esri-leaflet is just a leaflet plugin, so there should be no issue using with other libraries like jQuery Mobile http://www.gajotres.net/jquery-mobile-and-leaflet-integration/
... View more
10-23-2013
05:57 AM
|
0
|
0
|
946
|
|
POST
|
In addition to the ArcGIS JS API docs, I think there are a couple of great free resources. A great starter is Eloquent JavaScript. It's a great intro to JS. Since the API is built using Dojo, another good addition is the Dojo site. Although the Dojo docs have improved greatly over the past few years, I still find they are lacking in a lot of details when you really start digging in. It would help immensely if you also took a look around the sitepen site and their blog. Some good links from their site. http://www.sitepen.com/blog/2012/11/07/dojo-tutorial-dojo-start/ http://www.sitepen.com/blog/2012/12/06/learning-dojo-1-8/
... View more
10-22-2013
08:30 AM
|
0
|
0
|
1148
|
|
POST
|
Check out the links in this thread on the same subject. http://forums.arcgis.com/threads/83026-creating-AMD-layer-file-Api-3.4
... View more
10-21-2013
07:34 AM
|
0
|
0
|
657
|
|
POST
|
Thansk for all your help John! Quick note on this, it looks like enabling .net extension support after AGS is installed wiped the Python27 directory on our server. The folder last updated time and date matches when we enabled that featue and no one else has access to the machine. I asked our IT group do a repair install and see if that fixes it. Just a word of caution.
... View more
10-11-2013
11:15 AM
|
0
|
0
|
1540
|
|
POST
|
I'm guessing your config is setting up your packages with a require(). You're loading that file before the AGSJS API in your script tags.
<script src="../../config/dojo.test.config.js"></script>
<script src="//js.arcgis.com/3.7compact/"></script>
Try flipping the order. Technically, there's no guarantee of order with script tags, but with so few being used on the page, I'd look at that possibility.
... View more
10-10-2013
12:09 PM
|
0
|
0
|
1845
|
|
POST
|
I go back and forth using mocha/chai/sinon or jasmine for testing with PhantomJS. I've gotten that multiple define error when a test runs before, but just ignored it and it worked fine. I don't get the require not defined error though. My specrunner.html looks like below, where ArcGIS JS API is first script tag and mocha/chai/sinon added just before these lines.
<script type="text/javascript" src="spec/main.js"></script>
<script>
var dojoConfig = {
isDebug: false,
isJasmineTestRunner: true, // prevents parser in main.js from running
has: {'dojo-undef-api': true}
};
mocha.setup('bdd');
mocha.ignoreLeaks();
</script>
This didn't cause any issues that I could remember. In my main.js I use this for my require if it matters.
/**
* Method same as with requirejs
* http://www.bennadel.com/blog/2393-Writing-My-First-Unit-Tests-With-Jasmine-And-RequireJS.htm
**/
require([
'require',
'dojo/ready'
], function (require, ready) {
ready(function () {
require([
/* helper modules */
'spec/js/helpers/sampleHelperSpec'
], function () {
(window.mochaPhantomJS || window.mocha).run();
});
});
});
Heck, I think I'll go back now and load all the libraries from the require statement and see what happens. Like I said, running my tests from Grunt, I ocassionally get the multipledefine error, but it doesn't seem to break my tests. I got a lot of help from the AGRC repo as they use Jasmine with for headless testing with Grunt without much issue. https://github.com/agrc/AGRCJavaScriptProjectBoilerPlate/tree/master/src/app/tests Here's a blog post from Dave Bouwman using Jasmine for his headless testing of the API at Esri. http://blog.davebouwman.com/2013/07/26/automated-headless-unit-tests-with-esri-js-api/ Maybe, and I can't say for sure, but looking at your require() statement.
require(["../../node_modules/chai/chai.js",
"../../node_modules/mocha/mocha.js",
"../../node_modules/sinon/lib/sinon.js"], function (chai) {
mocha.setup('bdd');
mocha.reporter('html');
expect = chai.expect;
require(["test/unit/MapApp"], function () {
if (window.mochaPhantomJS) {
mochaPhantomJS.run();
} else {
mocha.run();
}
});
});
You may want to move your unit test into a define() in another module required from you're config. This way you can load another context sensitive require() to load your tests. Context sensitive require() is useful for conditional loading of modules, like the tests. That's a big maybe, I can't say for sure. http://dojotoolkit.org/reference-guide/1.9/loader/amd.html#context-sensitive-require
... View more
10-10-2013
11:40 AM
|
0
|
0
|
1845
|
|
POST
|
Here is what I've used in my specrunner.html I think you need to do the mocha set before the API loads, then when it's loaded, you can start mocha.
<div id="mocha"></div>
<div id="map"></div>
<script type='text/javascript' src='//js.arcgis.com/3.7'></script>
<script type="text/javascript" src="node_modules/mocha/mocha.js"></script>
<script type="text/javascript" src="node_modules/chai/chai.js"></script>
<script type='text/javascript' src='lib/sinon-1.7.3.js'></script>
<!-- source files -->
<script type="text/javascript" src="spec/main.js"></script>
<script>
var dojoConfig = {
isDebug: false,
has: {'dojo-undef-api': true}
};
mocha.setup('bdd');
mocha.ignoreLeaks();
</script>
The in main.js I'm able to use require() to setup my config.
(function () {
/** packages and configuration stuff **/
/**
* Method same as with requirejs
* http://www.bennadel.com/blog/2393-Writing-My-First-Unit-Tests-With-Jasmine-And-RequireJS.htm
**/
require([
'require',
'dojo/ready'
], function (require, ready) {
ready(function () {
require([
], function () {
(window.mochaPhantomJS || window.mocha).run();
});
});
});
})(this);
I got help setting this up from the AGRC guys repo. https://github.com/agrc/AGRCJavaScriptProjectBoilerPlate/tree/master/src/app/tests They even figured out how to build StubModule to stub our Dojo/Esri modules for testing, which is pretty cool. https://github.com/agrc/StubModule That's why in the dojoConfig, I set up
has: {'dojo-undef-api': true}
This allows the stubbing of Dojo modules. When the tests run, I would still get a multipledefine error, but it was ignored and tests still worked. I run these using Grunt if that matters. Similar methods should work for Jasmine too.
... View more
10-10-2013
11:31 AM
|
0
|
0
|
1845
|
|
POST
|
I did something similar a while ago. You can use dojo/dom-geometry to get get the needed points and convert them to a geometry. Project is here https://github.com/odoe/AGSDragDropHandler You can read comments in the CoffeeScript file https://github.com/odoe/AGSDragDropHandler/blob/master/src/DragDropHandler.coffee Generated JavaScript https://github.com/odoe/AGSDragDropHandler/blob/master/src/DragDropHandler.js Here is a sample https://github.com/odoe/AGSDragDropHandler/tree/master/example/src Relevant code // create a new instance of the DragDropHandler handler = new DragDropHandler(); // listen for custom "itemdrop" event handler.on("itemdrop", function(evt) { var data; console.log('item dropped', evt); data = { pt: new esri.geometry.Point(evt.x, evt.y), url: domAttr.get(evt.dragsource, 'src'), id: domAttr.get(evt.dragsource, 'id') }; console.log('add to map', data); return mapView.addPoint(data); }); The mapView.addPoint function addPoint: function(data) { var graphic, mp, pms, template; console.log('data', data); mp = esri.geometry.toMapGeometry(this.map.extent, this.map.width, this.map.height, data.pt); // convert to map geometry pms = new esri.symbol.PictureMarkerSymbol(); pms.setUrl(data.url); /* # Set width and heigth accordingly. # If you need to set an offset for a # pin type marker, do that also */ pms.setWidth(24); pms.setHeight(24); /* # Normally, I would et the attribute data from another, non-spatial data source, # and link it via an id or some other attribute, for now, I'll just use a simple # id field. I'll leave this up to you how you want to populate attributes */ template = new esri.InfoTemplate("Type of Point", "Type: ${TYPE}"); graphic = new esri.Graphic(mp, pms, { TYPE: data.id }, template); return this.map.graphics.add(graphic); } The esri.geometry.toMapGeometry is what will convert screen geometry to map geometry. https://developers.arcgis.com/en/javascript/jsapi/namespace_geometry-amd.html#toMapGeometry I put up a blog post about some issues with getting the correct screen point if your map doesn't take up the whole window of the browser, and who dojo/dom-geometry just worked as intended. http://odoe.net/blog/?p=371 And here is a demo. http://www.odoe.net/apps/dndeditdemo/
... View more
10-09-2013
12:24 PM
|
0
|
0
|
1820
|
|
POST
|
Well, what do you know. .NET Extension Support was disabled on our install. I don't actually get to install the software, so I had an IT guy double check and sure enough, once we enable it, we can use SOEs as planned. Surprised I could actually add an extension if it that option was disabled. Thanks!
... View more
10-09-2013
09:30 AM
|
1
|
0
|
1540
|
|
POST
|
Are you trying to get documentation or intellisense? You may be able to get intellisense by downloading the API locally and pointing WebStorm the directory as your Dojo install, I have not tried it this way, but it did not work when I pointed it to the CDN. But for docs, WebStorm will look to external sites to pull in the docs via URL. You can check WebStorm library setup and doc instructions here. http://www.jetbrains.com/webstorm/webhelp/documentation-look-up-in-external-javascript-libraries.html
... View more
10-09-2013
06:43 AM
|
0
|
0
|
629
|
|
POST
|
Just a quick update on this. You can get the mapOptions and operationalLayers (probably most tedious to process) by using the PrintTask. PrintTask.prototype._getPrintDefinition(map); After that you'd need to mixin the layoutOptions with your legendOptions if needed and the extra parameters. Send an object as
{
Web_Map_as_JSON: <web map as json>,
Format: <jpg, pdf, whatever>,
Layout_Template: <template name>
}
You're good to go.
... View more
10-08-2013
12:51 PM
|
0
|
1
|
3493
|
|
POST
|
We recently deployed ArcGIS Server 10.1 and had previously used MVC web services with ArcObjects to do our heavy lifting. Our services broke with 10.1, it's my understanding we are better suited to use SOEs. To just do some imple testing and see how we could enable the SOE on a service and interact with it, we published the REST SOE Template from Visual Studio and deployed it to our server with no errors. However, when we tried to enable it on a map services capabilities we got the error "ClassFactory cannot supply requested class" and the service failes to start. Disable the SOE and the service starts fine. I'm not sure how to test this locally to see where this might occur, but I assumed if I just published the template without changing anything, I shouldn't have an issue. For reference, our ArcGIS Server install is 10.1.1 (build 3143). Any insights would be appreciated. Could there be an issue with our install? Should we try a reinstall? Thanks.
... View more
10-07-2013
09:41 AM
|
1
|
4
|
6235
|
|
POST
|
There's a slight typo in that original code sample. new esri.esri.dijit.InfoWindow should be new esri.dijit.InfoWindow This works.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=7,IE=9, IE=10">
<!--The viewport meta tag is used to improve the presentation and behavior of the samples
on iOS devices-->
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<title></title>
<link rel="stylesheet" href="http://js.arcgis.com/3.7/js/dojo/dijit/themes/claro/claro.css">
<link rel="stylesheet" href="http://js.arcgis.com/3.7/js/esri/css/esri.css">
<style>
html, body {
height: 100%; width: 100%;
margin: 0; padding: 0;
}
body{
background-color:white; overflow:hidden;
font-family: "Kimberley", sans-serif
}
#header {
-moz-border-radius: 5px;
border-radius:5px;
margin:5px;
padding-top: 4px;
padding-right: 15px;
background-color:#211E21;
color:#FFC98C;
font-size:16pt; text-align:right;font-weight:bold;
border: solid 2px #2A2F30;
height:55px;
}
#subheader {
font-size:small;
color: #cfcfcf;
text-align:right;
padding-right:20px;
}
#map {
margin:5px;
border:solid 4px #2A2F30;
padding:0px;
}
.shadow{
-moz-border-radius: 6px;
-webkit-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: 0 8px 6px -6px #999;
-moz-box-shadow: 0 8px 6px -6px #999;
box-shadow: 0 8px 6px -6px #999;
}
</style>
<script>var dojoConfig = { parseOnLoad: true };</script>
<script src="http://js.arcgis.com/3.7/"></script>
<script>
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("esri.map");
dojo.require("dojo.number");
dojo.require("esri.layers.FeatureLayer");
dojo.require("esri.dijit.InfoWindow");
var map, trailLayer;
var template;
var soeParams;
var soeURL = "http://sampleserver4.arcgisonline.com/ArcGIS/rest/services/Elevation/ESRI_Elevation_World/MapServer/exts/ElevationsSOE/ElevationLayers/1/GetElevationProfile";
function init() {
//This sample requires a proxy page to handle communications with the ArcGIS Server services. You will need to
//replace the url below with the location of a proxy on your machine. See the 'Using the proxy page' help topic
//for details on setting up a proxy page.
esri.config.defaults.io.proxyUrl = "../proxy/proxy.php";
map = new esri.Map("map", {
basemap: "satellite",
center: [-117.069, 36.215],
zoom: 13
});
var infoWindow = new esri.dijit.InfoWindow({}, dojo.create("div", null, map.root));
map.infoWindow.resize(625, 240);
infoWindow.startup();
map.setInfoWindow(infoWindow);
//setup SOE parameters
soeParams = {};
soeParams.ImageWidth = 600;
soeParams.ImageHeight= 200;
soeParams.BackgroundColorHex="#ffffff";
soeParams.DisplaySegments=false;
soeParams.f="json";
//add the trails feature layer to the map
template = new esri.InfoTemplate();
template.setTitle("<b>${notes}</b>");
template.setContent(getTextContent);
trailLayer = new esri.layers.FeatureLayer("http://sampleserver5.arcgisonline.com/ArcGIS/rest/services/LocalGovernment/Recreation/MapServer/1", {
mode: esri.layers.FeatureLayer.MODE_ONDEMAND,
infoTemplate:template,
outFields: ["*"]
});
//create a new renderer for the feature layer
var lineSymbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,new dojo.Color([0,255,0,.70]), 5);
trailLayer.setRenderer(new esri.renderer.SimpleRenderer(lineSymbol));
map.addLayer(trailLayer);
//add world place names to the map
var referenceLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Boundaries_and_Places/MapServer");
map.addLayer(referenceLayer);
}
//Generate the content for the info window when the feature is clicked.
function getTextContent(graphic) {
var geometry = esri.geometry.webMercatorToGeographic(graphic.geometry);
var deferred = new dojo.Deferred();
//generate elevation profile
soeParams.InputPolyline = dojo.toJson(geometry.toJson());
esri.request({
url: soeURL,
content: soeParams,
callbackParamName: "callback",
load: function(fset) {
deferred.callback("<img src='" + fset.profileImageUrl + "'/>");
},
error: function(error) {
deferred.errback("Error occurred while generating profile");
}
});
return deferred;
}
dojo.ready(init);
</script>
</head>
<body class="claro">
<div id="mainWindow"
data-dojo-type="dijit.layout.BorderContainer"
data-dojo-props="design:'headline', gutters:false"
style="width:100%; height:100%;">
<div id="header" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'">
Click a trail to view the elevation profile
</div>
<div id="map" data-dojo-type="dijit.layout.ContentPane" class="shadow" data-dojo-props="region:'top'"></div>
</div>
</body>
</html>
... View more
10-04-2013
01:20 PM
|
0
|
0
|
2745
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 05-19-2026 02:12 PM | |
| 1 | 04-24-2026 11:01 AM | |
| 2 | 04-21-2026 07:06 AM | |
| 1 | 02-27-2026 06:31 AM | |
| 1 | 01-13-2026 02:15 PM |
| Online Status |
Online
|
| Date Last Visited |
3 hours ago
|