|
POST
|
Now I know this is due to the lack of CORS support on that server and I can see this by the error message and in most cases it can be ignored, but this is stopping the function from being run. If I can the crafted URL and paste it into a browser, it executes fine. Any ideas on how one can query the Portal API without this happening? Without CORS support, browsers won't let you do a cross-domain POST due to same origin policy. Use a proxy page.
... View more
08-27-2012
05:26 AM
|
0
|
0
|
1221
|
|
POST
|
Were you able to try my suggestion of using dojo.clone inside of your callback to dojo.map?
... View more
08-26-2012
08:00 PM
|
0
|
0
|
2637
|
|
POST
|
When I added the point clustering js to my project with other js files, the error "esri is not defined" occurred. How to fix this bugs? Thanks! This usually happens when you try to reference something in the library before it's been loaded. We mention this in the Migrating to 3.0 doc.
... View more
08-26-2012
06:57 PM
|
0
|
0
|
2013
|
|
POST
|
Unfortunately you probably won't be able to get any JSON from the printing process as soon as you click the button, it'll lock the browser up with an "unresponsive script" response. I.E will report stack issues. With firebug closed (not recording) the button will change to "printing" but nothing will print and the button stays like that until you refresh the page again. When your app locks up the browser, or you see errors like you've described, the problem is almost certainly something to do with some JS you're running. In this particular case, since you're using references to each graphic's attributes object to create your store, Dojo then modifies the attributes object when you use them to create an ItemFileReadStore. This leads to the issue you're seeing when you try to print the map (there would also probably be some weirdness in your app if you tried to do something like display map graphic attributes when they're clicked). The underlying print code in the JS API processes all map layers (including graphics) to remove object properties that are undefined or null (two reasons for this: it's a waste to send properties that are undefined or null and the print service doesn't handle those types of values elegantly). When the JS API print code tries to process the graphic's attributes after they've been put through Dojo's store creation process it gets into an infinite loop somewhere. I haven't completely figured out the details on this, but it's definitely the source of your error. A simple fix would be to clone graphic.attributes instead of referencing it directly in your array of objects used to create your store: var items = dojo.map(results, function (result) { var graphic = result.feature; var sms = esri.symbol.SimpleMarkerSymbol; var sls = esri.symbol.SimpleLineSymbol; graphic.setSymbol( new sms( "circle", 14, new sls("solid", new dojo.Color([6, 105, 140]), 1), new dojo.Color([6, 105, 140, 0.5]) ) ); app.map.graphics.add(graphic); return dojo.clone(graphic.attributes); }); Here's a full working example that prints when you have graphics (I was testing with graphics that come back when searching for 1): <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="X-UA-Compatible" content="IE=7, IE=9" /> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=yes"/> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dijit/themes/soria/soria.css"/> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dojox/grid/resources/Grid.css"/> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dojox/grid/resources/soriaGrid.css"/> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/esri/dijit/css/Popup.css"/> <link rel="stylesheet" type="text/css" href="https://community.esri.com/css/beacon.css" /> <link rel="stylesheet" type="text/css" href="https://community.esri.com/css/tabs.css" /> <style> html, body { height: 100%; width: 100%; margin: 0; padding: 0; } #map { padding:0; } </style> <script type="text/javascript"> dojoConfig = { parseOnLoad: true, locale: "en-gb" } </script> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.1"></script> <script type="text/javascript"> dojo.require("esri.map"); dojo.require("dijit.form.Button"); dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("dijit.layout.TabContainer"); dojo.require("dijit.Toolbar"); dojo.require("dojox.grid.DataGrid"); dojo.require("dojo.data.ItemFileReadStore"); dojo.require("dojo.data.ItemFileWriteStore"); dojo.require("esri.dijit.Print"); dojo.require("esri.tasks.find"); var app = {}; app.printUrl = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task"; function init() { esri.config.defaults.io.proxyUrl = "/arcgisserver/proxy/proxy.ashx"; app.map = new esri.Map("map", { extent: new esri.geometry.Extent({ "xmin": 1073230, "ymin": 4793770, "xmax": 1514290, "ymax": 4960990, "spatialReference": { "wkid": 2193 } }), logo: false, wraparound180: true }); var baseMapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.co.nz/ArcGIS/rest/services/Generic/newzealand/MapServer"); app.map.addLayer(baseMapLayer); dojo.connect(app.map, 'onLoad', function () { dojo.connect(dijit.byId('map'), 'resize', app.map, app.map.resize); var printMap = esri.request({ "url": app.printUrl, "content": { "f": "json" } }); printMap.then(print, error); }); } function print(p) { var template = new esri.tasks.PrintTemplate(); template.layout = "A4 Landscape"; template.format = "pdf"; template.layoutOptions = { "authorText": "", "copyrightText": "Copyright " + new Date().getFullYear(), "titleText": "Groundwater", "scalebarUnit": "Kilometers" }; printer = new esri.dijit.Print({ "map": app.map, "templates": [template], url: app.printUrl }, dojo.byId("print")); printer.startup(); } function doFind() { var s = dojo.byId("query").value var findParams = new esri.tasks.FindParameters(); var findTask = new esri.tasks.FindTask("http://gis.es.govt.nz/ArcGIS/rest/services/Groundwater/MapServer"); findParams.layerIds = [0]; findParams.searchFields = ["Well_No"]; findParams.returnGeometry = true; findParams.outSpatialReference = app.map.spatialReference; findParams.searchText = s; findTask.execute(findParams, showResults); } function error(err) { alert("Error: " + err); } function showResults(results) { app.map.graphics.clear(); if (results.length > 0) { var items = dojo.map(results, function (result) { var graphic = result.feature; var sms = esri.symbol.SimpleMarkerSymbol; var sls = esri.symbol.SimpleLineSymbol; graphic.setSymbol( new sms( "circle", 14, new sls("solid", new dojo.Color([6, 105, 140]), 1), new dojo.Color([6, 105, 140, 0.5]) ) ); app.map.graphics.add(graphic); return dojo.clone(graphic.attributes); }); console.log("items: ", items); var data = { 'identifier': 'OBJECTID', 'items': items } var store = new dojo.data.ItemFileReadStore({ data: data }); var grid = new dojox.grid.DataGrid({ 'id': 'grid', 'store': store, 'structure': [{ 'name': 'Well Number', 'field': 'WELL_NO', 'width': '200px' }], 'rowSelector': '0px' }); grid.placeAt("records"); grid.startup(); } else { alert("No results found matching your criteria."); } } dojo.ready(init); </script> </head> <body class="soria"> <div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline'" style="width:100%; height:100%; margin:0;" id="workspace"> <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'" id="header"> <div id="toolbar" data-dojo-type="dijit.Toolbar"> <div id="print"></div> </div> </div> <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'left'" style="width: 240px;" id="side"> <div dojoType="dijit.layout.TabContainer" id="tabContainer" style="width: 100%; height: 100%;" tabPosition="top"> <div dojoType="dijit.layout.ContentPane" title="Main" id="main"> <h2>Search For...</h2> <div id="search"> <p>Look For:</span> <br/> <input type="text" id="query" style="width: 222px" /> </p> </div> <p>Look In: <br/> <select id="lookIn" style="width: 228px"> <option value="WN">Well Number</option> </select> </p> <p> <button data-dojo-type="dijit.form.Button" data-dojo-props='onClick:function(){ doFind();}, value:"Search"'>Search</button> </p> </div> <div dojoType="dijit.layout.ContentPane" title="Results" id="results"> <div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'left'" style="width: 240px;" id="records"></div> </div> </div> </div> <div id="map" data-dojo-props="region:'center'" data-dojo-type="dijit.layout.ContentPane"></div> </div> </body> </html>
... View more
08-26-2012
06:54 PM
|
0
|
0
|
5272
|
|
POST
|
It is not currently possible to use only a graphics layer (or a feature layer in your map). A dynamic or tiled map service layer is required. What you can do is subclass dynamic map service layer and override getImageUrl so that it does nothing. This way you end up with an empty layer, and you can use whatever spatial reference you like. This is shown in the writing a class conceptual help topic and here's an example of it: http://servicesbeta.esri.com/demos/using-classes-with-javascript/legacy/empty_basemap.html
... View more
08-24-2012
07:45 AM
|
0
|
0
|
2521
|
|
POST
|
I tweaked your code to test, obviously I can't acces your Groundwater service:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=7, IE=9" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=yes"/>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dijit/themes/soria/soria.css"/>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dojox/grid/resources/Grid.css"/>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/dojo/dojox/grid/resources/soriaGrid.css"/>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/3.1/js/esri/dijit/css/Popup.css"/>
<link rel="stylesheet" type="text/css" href="https://community.esri.com/css/beacon.css" />
<link rel="stylesheet" type="text/css" href="https://community.esri.com/css/tabs.css" />
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
#map { padding:0; }
</style>
<script type="text/javascript">
dojoConfig = {
parseOnLoad: true,
locale: "en-gb"
}
</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=3.1"></script>
<script type="text/javascript">
dojo.require("esri.map");
dojo.require("dijit.form.Button");
dojo.require("dijit.layout.BorderContainer");
dojo.require("dijit.layout.ContentPane");
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.Toolbar");
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("dojo.data.ItemFileWriteStore");
dojo.require("esri.dijit.Print");
dojo.require("esri.tasks.find");
var app = {};
// app.printUrl = "http://esweb1/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export Web Map Task";
app.printUrl = "http://sampleserver6.arcgisonline.com/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export%20Web%20Map%20Task";
function init() {
// esri.config.defaults.io.proxyUrl = "/arcgisserver/proxy/proxy.ashx";
esri.config.defaults.io.proxyUrl = "/~dswingley/esri_js/proxy/proxy.php";
app.map = new esri.Map("map", {
extent: new esri.geometry.Extent({
"xmin": 1073230,
"ymin": 4793770,
"xmax": 1514290,
"ymax": 4960990,
"spatialReference": {
"wkid": 2193
}
}),
logo: false,
wraparound180: true
});
var baseMapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.co.nz/ArcGIS/rest/services/Generic/newzealand/MapServer");
app.map.addLayer(baseMapLayer);
console.log("this.opacity: ", this.opactiy);
// var service = new esri.layers.ArcGISDynamicMapServiceLayer("http://esweb1/arcgis/rest/services/Public/Groundwater/MapServer", {
// opacity: this.opacity,
// id: "emap"
// });
// app.map.addLayer(service);
var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://services.arcgisonline.co.nz/arcgis/rest/services/LINZ/geotiffs/MapServer", { "opacity": this.opacity });
app.map.addLayer(dynamicMapServiceLayer);
dojo.connect(app.map, 'onLoad', function () {
dojo.connect(dijit.byId('map'), 'resize', app.map, app.map.resize);
var printMap = esri.request({
// "url": "http://esweb1/arcgis/rest/services/Utilities/PrintingTools/GPServer/Export Web Map Task",
"url": app.printUrl,
"content": {
"f": "json"
}
});
printMap.then(print, error);
});
}
function print(p) {
var template = new esri.tasks.PrintTemplate();
template.layout = "A4 Landscape";
template.format = "pdf";
template.layoutOptions = {
"authorText": "",
"copyrightText": "Copyright " + new Date().getFullYear(),
"titleText": "Groundwater",
"scalebarUnit": "Kilometers"
};
printer = new esri.dijit.Print({
"map": app.map,
"templates": [template],
url: app.printUrl
}, dojo.byId("print"));
printer.startup();
}
function doFind() {
var s = dojo.byId("query").value
var findParams = new esri.tasks.FindParameters();
var findTask = new esri.tasks.FindTask("http://esweb1/ArcGIS/rest/services/Public/Groundwater/MapServer");
findParams.layerIds = [0];
findParams.searchFields = ["Well_No"];
findParams.returnGeometry = true;
findParams.outSpatialReference = app.map.spatialReference;
findParams.searchText = s;
findTask.execute(findParams, showResults);
}
function error(err) {
alert("Error: " + err);
}
function showResults(results) {
app.map.graphics.clear();
if (results.length > 0) {
var items = dojo.map(results, function (result) {
var graphic = result.feature;
graphic.setSymbol(new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_CIRCLE, 14,
new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,
new dojo.Color([6, 105, 140]), 1), new dojo.Color([6, 105, 140, 0.5])));
app.map.graphics.add(graphic);
return graphic.attributes;
});
var data = {
'identifier': 'OBJECTID',
'items': items
}
var store = new dojo.data.ItemFileReadStore({
data: data
});
//destroy("grid"); //remove the grid so that the new results are bound fresh
var grid = new dojox.grid.DataGrid({
'id': 'grid',
'store': store,
'structure': [{
'name': 'Well Number',
'field': 'WELL_NO',
'width': '200px'
}],
'rowSelector': '0px'
});
grid.placeAt("records");
grid.startup();
} else {
alert("No results found matching your criteria.");
}
}
dojo.ready(init);
</script>
</head>
<body class="soria">
<div data-dojo-type="dijit.layout.BorderContainer" data-dojo-props="design:'headline'"
style="width:100%; height:100%; margin:0;" id="workspace">
<div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'top'"
id="header">
<div id="toolbar" data-dojo-type="dijit.Toolbar">
<div id="print"></div>
</div>
</div>
<div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'left'"
style="width: 240px;" id="side">
<div dojoType="dijit.layout.TabContainer" id="tabContainer" style="width: 100%; height: 100%;"
tabPosition="top">
<div dojoType="dijit.layout.ContentPane" title="Main" id="main">
<h2>Search For...</h2>
<div id="search">
<p>Look For:</span>
<br/>
<input type="text" id="query" style="width: 222px" />
</p>
</div>
<p>Look In:
<br/>
<select id="lookIn" style="width: 228px">
<option value="WN">Well Number</option>
</select>
</p>
<p>
<button data-dojo-type="dijit.form.Button" data-dojo-props='onClick:function(){ doFind();}, value:"Search"'>Search</button>
</p>
</div>
<div dojoType="dijit.layout.ContentPane" title="Results" id="results">
<div data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'left'"
style="width: 240px;" id="records"></div>
</div>
</div>
</div>
<div id="map" data-dojo-props="region:'center'" data-dojo-type="dijit.layout.ContentPane"></div>
</div>
</body>
</html>
Printing works with that code so I'm guessing there's something specific to features in your Groundwater service. Two things we can look at: �??post the JSON (either as a code sample or an attached file) returned from your Groundwater service? That way I can create some graphics from that and see if it breaks printing. You can get to the JSON via firebug's Net section �??post the JSON that's being sent to the print service, also available from firebug's Net section
... View more
08-23-2012
09:01 PM
|
0
|
0
|
5272
|
|
POST
|
It sounds like you've done quite a bit of research/testing but the easiest way to get help is to post code that reproduces the issue. Can you post a simple test page that shows the problem?
... View more
08-23-2012
06:18 PM
|
0
|
0
|
5272
|
|
POST
|
I think this conversation is muddying this thread Agreed. Apologies to OP for highjacking the thread. Still hoping to see a simple repro case.
... View more
08-22-2012
01:30 PM
|
0
|
0
|
1401
|
|
POST
|
John's correct�?? the "errors" you see are related to figuring out whether or not a server supports CORS and this was new with version 3.0 of the JS API. These errors will go away when the servers you mentioned are upgraded to AGS 10.1. IIRC, that's happening this fall. Until then, these errors can be safely ignored.
... View more
08-22-2012
11:09 AM
|
0
|
0
|
2229
|
|
POST
|
I agree that is one approach, depends how easy/quick it is for the OP to snap off just the bit that's causing issues, always worth having other approaches. To return that one dojo uncompressed file (for many people) means changing one line in the handler that returns it, IMO that's not a hardship. Not everyone is aware of all the options. The reason I recommended an alternative approach is that in ~4 years of developing with the API, I cannot recall a single instance of solving a problem by using uncompressed vs. compressed Dojo source files. Is that how you're set up locally? To me, suggesting this approach seems like a rabbit hole that could easily be avoided by following the normal web dev approach of eliminating complexity to create a simple repro case, sharing that with the community and asking for help.
... View more
08-22-2012
07:41 AM
|
0
|
0
|
1401
|
|
POST
|
Either way the dojo file is uncompressed and might help this chap find his issue. My opinion is that the best approach to getting to the bottom of this error is to post a simple page that can reproduce the error. That way we'll quickly be able to find out if the error being described is in his code or in the JS API. It's more trouble than it's worth to configure your local environment to use uncompressed Dojo files, IMO.
... View more
08-22-2012
07:28 AM
|
0
|
0
|
3343
|
|
POST
|
Can you strip the example right back so it's just a simple map with a single basemap, and see if that works? Then progressively add features until it breaks. Are you able to share your site's URL? Doing one or both of these will be the simplest way for us to help you find a fix.
... View more
08-22-2012
07:09 AM
|
0
|
0
|
3343
|
|
POST
|
v2.4 shipped with uncompressed version of dojo.xd.js.uncompressed.js so you could try serving that, then if the cause is in there it will at least be readable. If it's in the ESRI stuff then you could pretty-print the JS on download and attach breakpoints (manually, if it's not automatically breaking) This is not true, 3.0 is the only version of the API where uncompress files were (mistakenly) included with the API download.
... View more
08-22-2012
07:08 AM
|
0
|
0
|
3343
|
|
POST
|
Try loading the .json file directly in your browser. If you still get a 404, and you're sure that the path to the file is correct, you probably need to configure IIS to server JSON: http://stackoverflow.com/q/332988/1934
... View more
08-22-2012
07:02 AM
|
0
|
0
|
2013
|
|
POST
|
Look for references to a variable named "json" in your code, or possibly the Kurogo code. That should point you in the right direction for the source of this error.
... View more
08-21-2012
10:19 AM
|
0
|
0
|
3343
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 01-23-2012 07:54 AM | |
| 1 | 05-28-2010 08:31 AM | |
| 1 | 11-12-2012 08:12 AM | |
| 3 | 02-23-2012 10:57 AM | |
| 1 | 06-27-2011 08:51 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|