|
POST
|
Storing the info in the MXD is a good workaround, but I need something guaranteed to work (ie, without the dependency on the MXD author to remember to make the change). What about doing something with a JSON request, like in this sample? Do you think this would work? The URL http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer/layers?f=json returns a JSON string containing the field names, but I can't work out how to access this using the JSON request methodology in that sample. Can you give any clues? Cheers, Steve
... View more
08-16-2011
05:17 AM
|
0
|
0
|
2629
|
|
POST
|
See the sample below, which adds a DynamicMapServiceLayer to a map using the URL: http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer Navigating to this REST endpoint in a browser shows the component Layers, and each layer's Fields. How can I retrieve this information programatically? I need a list of the available layers (0,1,2) and each layer's available fields (eg layer 0 contains objectid, lifecyclestatus, incident_number, etc) My goal is to add this information to a Query function, so I need to know that I can search layer 1 for the field collection_time, etc. Looping through the layerInfos tells me about each available layer - how can I retrieve information on the fields? (One option is to create a new feature layer from each layer and add it to the map, but I'd really like to avoid this workaround). Thanks, Steve <!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" />
<!--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>layer infos</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/dojo/dijit/themes/claro/claro.css">
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.4"></script>
<script type="text/javascript">
dojo.require("esri.map");
function init() {
var map = new esri.Map("map");
var basemap = new esri.layers.ArcGISTiledMapServiceLayer("http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer");
map.addLayer(basemap);
var url = "http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer/";
var dynLayer = new esri.layers.ArcGISDynamicMapServiceLayer(url);
map.addLayer(dynLayer);
dojo.connect(dynLayer, "onLoad", function() {
var infos = dynLayer.layerInfos;
for (var i = 0; i <= infos.length - 1; i++) {
var layerId = infos.id;
var restEndPoint = url + layerId;
//restEndPoint is the layer's URL - how can I retrieve its fields?
}
});
}
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
<div id="map" style="width:900px; height:600px; border:1px solid #000;"></div>
</body>
</html>
... View more
08-15-2011
09:04 PM
|
0
|
10
|
4304
|
|
POST
|
you could try calling the 'cancel()' method before making another call. The code below is intended to show the general concepts only. Hi John, Thanks very much for posting this - it looks promising, but I'm finding that the Cancel method doesn't seem to have any effect. Using execute2 (with the Cancel First button), try searching for A then immediately Z. I'm finding that the results for Z are returned first, but then a few seconds later the results for A overwrite the Z results. Or try searching for A then immediately hitting Cancel - the results are still returned. This implies that the Cancel hasn't actually worked in either case. It looks like the best option will be to disable the interface until the query has responded, before allowing a subsequent query. Cheers, Steve
... View more
08-15-2011
04:49 PM
|
0
|
0
|
2382
|
|
POST
|
The days of a web mapping interface that includes a checklist of 'traditional' desktop GIS elements - OV Map, toolbar, etc. - have arguably passed. There is a movement toward more specialized web applications in greater numbers than one single application that tries to do it all Great points, Jeff.
... View more
08-15-2011
03:51 PM
|
0
|
0
|
1184
|
|
POST
|
can I save it in backend(as layer or something) for future use? so that the user need not upload each time? I'm not sure, but I don't think this is possible within the ArcGIS Server JSAPI. You might be able to automate something using an external process, by saving the values at the end of a session, storing them somewhere, and re-loading them when the next session starts. How to actually do this is totally beyond my knowledge, but hopefully someone can help. You could also try posting the question on http://gis.stackexchange.com Good luck, Steve
... View more
08-09-2011
08:56 PM
|
0
|
0
|
2304
|
|
POST
|
Can we dynamically create a feature layer(or editable layer) and save it on server?, so that the user can view the data in future and edit data. I don't know about making it editable, but you can create a feature layer from a feature collection (which you could generate from your CSV file). See the example here for some pointers. Good luck, Steve
... View more
08-09-2011
08:35 PM
|
0
|
0
|
2304
|
|
POST
|
Note that Google don't allow the use of their maps on an intranet site without paying for a premier license. http://code.google.com/apis/maps/terms.html says: 9.1.1 General Rules. (b) Public Access (No Firewall). Your Maps API implementation must not (i) operate only behind a firewall; or (ii) only on an internal network (except during the development and testing phase); or (iii) in a closed community (for example, through invitation-only access).
... View more
08-09-2011
03:47 PM
|
0
|
0
|
1070
|
|
POST
|
When you code runs the first time, the queryEvent is null or undefined. So it will almost be certain that you will catch an exception -dojo.stopEvent(undefined); I'd expect it to throw an error the first time, but not subsequent times. And since it's inside a try/catch, this is a handled error so it should have no effect other than writing something to the console (right?). I think stopping a query complete event does not really service your purpose. It basically tries to stop an already completed query process not an query that is under process. That is probably why it does not working. Yeah I think you might be right. Thanks anyway! Cheers, Steve
... View more
08-09-2011
03:43 PM
|
0
|
0
|
2382
|
|
POST
|
To everyone else with a problem, what browser are you using? It's not working for me in IE8, Chrome 13 or Firefox 5 - I need to move the map first before the popup works. Hope this helps, Steve
... View more
08-09-2011
03:36 PM
|
0
|
0
|
2003
|
|
POST
|
A while ago, Derek Swingley showed how to use Google Maps as a background layer: How about moving to the full ArcGIS API for JavaScript and using this sample to get Google Maps in your JS app: http://gmaps-utility-gis.googlecode.com/svn/tags/gmapslayer/1.0/docs/examples.html
<script type="text/javascript" src="http://gmaps-utility-gis.googlecode.com/svn/tags/gmapslayer/1.0/src/gmapslayer_compiled.js" ></script>
var gMapLayer = new gmaps.GoogleMapsLayer({visible:false, id:'googlemaps'});
map.addLayer(gMapLayer); This works really well when it's hard-coded (as long as your application is located on an externally-facing server - ie it won't work while testing on your hard drive). Can this be integrated with the BaseMap Gallery? The BaseMap Gallery reference shows how to add a new basemap:
var layer = new esri.dijit.BasemapLayer({
url:"http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/PublicSafety/PublicSafetyBasemap/MapServer"
});
var basemap = new esri.dijit.Basemap({
layers:[layer],
title:"Public Safety",
thumbnailUrl:"images/safetyThumb.png"
});
basemapGallery.add(basemap);
How can the Google Maps layer be used as the Basemap (which is expecting a BasemapLayer object)? Thanks, Steve
... View more
08-08-2011
09:17 PM
|
0
|
9
|
5086
|
|
POST
|
Heming, I'm not having any luck with this. Below is the code I'm trying (a modification of the Query No Map sample with the relevant changes highlighted):
<!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" />
<!--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>Query State Info without Map</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.4/js/dojo/dijit/themes/claro/claro.css">
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.4"></script>
<script type="text/javascript" language="Javascript">
dojo.require("esri.tasks.query");
dojo.require("esri.map");
var queryTask, query;
var queryEvent;
function init() {
//build query
queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5");
//dojo.connect(queryTask, "onComplete", showResults);
//build query filter
query = new esri.tasks.Query();
query.returnGeometry = true;
query.outFields = ["SQMI","STATE_NAME","STATE_FIPS","SUB_REGION","STATE_ABBR","POP2000","POP2007","POP00_SQMI","POP07_SQMI","HOUSEHOLDS","MALES","FEMALES","WHITE","BLACK","AMERI_ES","ASIAN","OTHER","HISPANIC","AGE_UNDER5","AGE_5_17","AGE_18_21","AGE_22_29","AGE_30_39","AGE_40_49","AGE_50_64","AGE_65_UP"];
}
function execute(population) {
query.where = "POP2007 >" + population;
//execute query
try {
dojo.stopEvent(queryEvent);
}catch(e){
console.log("error");
}
queryEvent = queryTask.execute(query,showResults);
}
function showResults(results) {
var s = "";
for (var i=0, il=results.features.length; i<il; i++) {
var featureAttributes = results.features.attributes;
for (att in featureAttributes) {
s = s + "<b>" + att + ":</b> " + featureAttributes[att] + "<br />";
}
}
dojo.byId("info").innerHTML = s;
}
dojo.addOnLoad(init);
</script>
</head>
<body>
Population is greater than: <input type="text" id="population" value="50000" />
<input type="button" value="Get Details" onclick="execute(dojo.byId('population').value);" />
<br />
<br />
<div id="info" style="padding:5px; margin:5px; background-color:#eee;">
</div>
</body>
</html>
Rather than monitoring the query's state in a variable I figured a try/catch statement should do the same thing, right? The problem is that the dojo.stopEvent declaration doesn't seem to have any effect. The NET tab in Firebug shows that the query takes around 2 seconds to execute. Pressing the button a few times quickly shows that the previous processes are not cancelled. Any clues? Cheers, Steve
... View more
08-08-2011
02:56 PM
|
0
|
0
|
2382
|
|
POST
|
My understanding (and I could be wrong) is that this is not possible when using a dynamic map layer. To change the symbology you need to use a Renderer, which applies to a Graphics Layer. A Feature Layer is a type of graphics layer, but a dynamic layer is not. See the diagram on the Feature layer help file:
Class hierarchy
esri.layers.Layer
|_ esri.layers.GraphicsLayer
|_ esri.layers.FeatureLayer
Therefore your options could be to display your data using a feature layer, or change the symbology at the ArcMap level. Hope this helps, Steve
... View more
08-07-2011
11:05 PM
|
0
|
0
|
623
|
|
POST
|
no probs, happy to have helped. I'll be interested to see the finished result if you can post it here.
... View more
08-04-2011
08:06 PM
|
0
|
0
|
4816
|
|
POST
|
The value is a clean URL like this: http://129.2.24.163/ArcGIS/rest/services/00_SMC_Environmental_Health/MapServer I'm a bit confused now, since this works: var rest_url = "http://129.2.24.163/ArcGIS/rest/services/00_SMC_Environmental_Health/MapServer";
var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer(rest_url);
map.addLayer(dynamicMapServiceLayer);
Can you examine rest_url at run-time in FireBug and ensure that it's a valid string? Sorry I haven't been able to help much 🙂 Steve
... View more
08-04-2011
05:13 PM
|
0
|
0
|
4816
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-17-2014 08:45 PM | |
| 1 | 03-15-2011 04:23 PM | |
| 1 | 10-18-2019 12:50 AM | |
| 3 | 01-22-2019 02:33 PM | |
| 1 | 09-26-2011 10:36 PM |
| Online Status |
Offline
|
| Date Last Visited |
10-20-2022
12:19 AM
|