|
POST
|
I would agree with Jeff, use dojo.date.locale to properly format the date values as strings. Below are some links that might be of some help: http://api.dojotoolkit.org/jsdoc/1.6/dojo.date.locale.format http://www.unicode.org/reports/tr35/tr35-4.html#Date_Format_Patterns
dojo.require("dojo.date.locale");
_covDate = new Date(myAttributes.RecordDate);
var _covDateStr = dojo.date.locale.format(_covDate, {
selector: 'date',
datePattern: 'MM/dd/yyyy'
});
... View more
09-14-2011
08:28 AM
|
0
|
0
|
6793
|
|
POST
|
Robin, [INDENT]try this:[/INDENT] store.setValue(item, "Company", " "); [INDENT]However, I would recommend you instead check out the 'formatter' and 'get' attributes of the '<th>' table element as they provide additional control of the displayed content in the cell. More information can be found here. [/INDENT] John
... View more
09-06-2011
04:13 PM
|
0
|
0
|
639
|
|
POST
|
Is the goal to draw the line? ...or the buffers? If you only want to draw the line, try something like this: function drawLine(x1,y1,x2,y2) {
// CREATE GEOMETRY USING WGS84 SPATIAL REFERENCE
var p1 = new esri.geometry.Point(x1, y1, new esri.SpatialReference({wkid:4326}));
var p2 = new esri.geometry.Point(x2, y2, new esri.SpatialReference({wkid:4326}));
var geographicGeometry = new esri.geometry.Polyline(new esri.SpatialReference({wkid:4326}));
geographicGeometry = geometry.addPath([p1,p2]);
// CONVERT GEOMETRY TO WEB MERCATOR
var mapGeometry = esri.geometry.geographicToWebMercator(geographicGeometry);
var symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255, 0, 0]), 3);
var graphic = new esri.Graphic(mapGeometry ,symbol);
map.graphics.add(graphic);
}
... View more
09-02-2011
03:57 PM
|
0
|
0
|
735
|
|
POST
|
Is that all the code? I'm not 100% sure, but I believe the error message alludes to an improper 'dojo.require(..)' statement. I believe the letter 'l' is not capitalized: dojo.require("esri.tasks.locator") So my guess is that this difference is causing issues. Try explicitly adding the dojo.require(...) above to see if it helps.
... View more
08-30-2011
08:17 AM
|
0
|
0
|
551
|
|
POST
|
I would agree with Derek and Steve; you need to be careful not to overwhelm the user experience with too much information. Keep it simple and only retrieve data from the server when necessary. Below is an example of how you can use dojo.Deferred and dojo.DeferredList to properly associate responses/results and the sources of the queries. <!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=no"/>
<title>Get Counties By State</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");
dojo.require("esri.tasks.query");
dojo.require("dojo.DeferredList");
function init() {
var map = new esri.Map("map");
var imageParameters = new esri.layers.ImageParameters();
imageParameters.format = "jpeg";
var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/Demographics/USA_Population_Density/MapServer", {
"imageParameters": imageParameters
});
map.addLayer(dynamicMapServiceLayer);
//
// GET STATE FEATURES
//
getStates(dynamicMapServiceLayer, 4);
}
// GET STATE FEATURES
function getStates(layer, subLayerIndex) {
var statesQueryDeferred = doQuery(layer, subLayerIndex, '1=1')
statesQueryDeferred.then(function(statesFeatueSet) {
// BUILD LIST OF QUERY WHERE STRINGS
var whereClauses = dojo.map(statesFeatueSet.features, function(statesFeature) {
return {
stateName: statesFeature.attributes.ST_ABBREV,
where: dojo.replace("ST_ABBREV = '{attributes.ST_ABBREV}'", statesFeature)
};
});
getCountiesByState(layer, 3, whereClauses);
});
}
//
// GET COUNTY COUNT FOR EACH STATE
//
function getCountiesByState(layer, subLayerIndex, whereClauses) {
// CREATE ARRAY OF DEFERREDS
var countiesDeferredArray = dojo.map(whereClauses, function(whereClause) {
// CREATE STATE NODE
var stateNode = dojo.create('div', {
'innerHTML': dojo.replace("{stateName} - ", whereClause)
}, 'countyInfo');
var countyCountNode = dojo.create('span', {
'id': dojo.replace("countyCount_{stateName}", whereClause),
'innerHTML': 'Searching...'
}, stateNode);
// RETURN QUERY DEFERRED
return doQuery(layer, subLayerIndex, whereClause.where);
}, this);
// CREATE DEFERRED LIST FROM ARRAY OF DEFERREDS
var countiesDeferredList = new dojo.DeferredList(countiesDeferredArray);
countiesDeferredList.then(function(responses) {
// WE GET ONE RESPONSE WHEN THEY'RE ALL DONE
dojo.forEach(responses, function(response, responseIndex) {
// FIND MATCHING WHERE CLAUSE
var whereClause = whereClauses[responseIndex];
// FIND STATE NODE
var stateNode = dojo.byId(dojo.replace("countyCount_{stateName}", whereClause));
// DO WE HAVE A SUCCESSFUL RESPONSE
if(response[0]) {
var countyFeatureSet = response[1];
// UPDATE STATE NODE WITH COUNTY COUNT
stateNode.innerHTML = dojo.replace("{features.length} counties", countyFeatureSet);
} else {
stateNode.innerHTML = 'Error...';
}
}, this);
});
}
//
// QUERY
//
function doQuery(layer, subLayerIndex, where) {
var query = new esri.tasks.Query();
query.returnGeometry = false;
query.outFields = ["*"]
query.where = where;
var queryTask = new esri.tasks.QueryTask(layer.url + "/" + subLayerIndex);
return queryTask.execute(query);
}
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
<div id="map" style="width:500px; height:300px; border:1px solid #000;"></div>
<ul id="countyInfo"></ul>
</body>
</html>
... View more
08-25-2011
10:48 AM
|
0
|
0
|
952
|
|
POST
|
If available, you could use the '/layers' REST endpoint to get back all the information you need in a single call. <!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=no"/>
<title>Create 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">
dojo.require("esri.map");
function init() {
var map = new esri.Map("map");
var imageParameters = new esri.layers.ImageParameters();
imageParameters.format = "jpeg";
var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/HomelandSecurity/operations/MapServer", {
"opacity":0.5,
"imageParameters":imageParameters
});
map.addLayer(dynamicMapServiceLayer);
// GET MAP SERVICE INFORMATION
getMapServiceInformation(dynamicMapServiceLayer.url);
}
// GET MAP SERVICE INFORMATION
function getMapServiceInformation(mapServiceUrl) {
var mapServiceInfoDeferred = esri.request({
url: dojo.replace("{0}/layers",[mapServiceUrl]),
content: {
f: 'json'
},
callbackParamName: "callback"
});
mapServiceInfoDeferred.then( function(response) {
// THE INFORMATION RETURNED HERE IS NOT THE SAME OBJECT/INSTANCE AS
// THE JS API LAYER CREATED ABOBE, IT'S JUST A SIMPLE JSON OBJECT
// REPRESENTATION OF MAP SERVICE INFORMAITON
dojo.forEach(response.layers, function(layerInfo) {
var layerInfoNode = dojo.create('li', {
'innerHTML': dojo.replace("<b>{name}</b> [{type}]",layerInfo),
'style':'font-size:larger;margin-bottom:20px;'
},'mapServiceInfo');
if(layerInfo.fields) {
var fieldsInfoNode = dojo.create('ul', {
},layerInfoNode);
dojo.forEach(layerInfo.fields, function(fieldInfo) {
var fieldInfoNode = dojo.create('li', {
'innerHTML': dojo.replace("<b>{name}</b> (<i>{alias}</i>) {type}",fieldInfo)
},fieldsInfoNode);
});
}
});
}, function(error) {
dojo.byId('mapServiceInfo').innerHTML = dojo.toJson(error);
});
}
dojo.addOnLoad(init);
</script>
</head>
<body class="claro">
<div id="map" style="width:500px; height:300px; border:1px solid #000;">
</div>
<ul id="mapServiceInfo">
</ul>
</body>
</html>
... View more
08-16-2011
09:11 AM
|
0
|
0
|
1683
|
|
POST
|
Steve, one simple way to handle this issue is by disabling the slider until the results come back. Another way is to use the dojo.Deferred returned by the QueryTask.execute(...) method. You could check the 'fired' property and only issue another call if it's not already running. Or you could try calling the 'cancel()' method before making another call. The code below is intended to show the general concepts only. <!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 queryDeferred;
function init() {
//build query
queryTask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/3");
//build query filter
query = new esri.tasks.Query();
query.returnGeometry = false;
query.outFields = ["*"];
}
function execute(stateName) {
// query already running query?
if(queryDeferred && (queryDeferred.fired > 0)) {
dojo.byId("info").innerHTML = "Query task is already running...";
} else {
dojo.byId("info").innerHTML = "Running query task: " + (new Date()).toLocaleTimeString();
//execute query
query.text = stateName;
queryDeferred = queryTask.execute(query);
queryDeferred.then(showResults,showError);
}
}
function execute2(stateName) {
// cancel previous query
cancelExecute();
dojo.byId("info").innerHTML = "Running query task: " + (new Date()).toLocaleTimeString();
//execute query
query.text = stateName;
queryDeferred = queryTask.execute(query);
queryDeferred.then(showResults,showError);
}
function showResults(results) {
dojo.byId("info").innerHTML = "Preparing 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;
}
function showError(error) {
dojo.byId("info").innerHTML += dojo.toJson(error);
}
function cancelExecute() {
if(queryDeferred && (queryDeferred.fired > 0)) {
queryDeferred.cancel();
dojo.byId("info").innerHTML = "Query task cancelled.";
} else {
dojo.byId("info").innerHTML = "Query task not running...";
}
}
dojo.addOnLoad(init);
</script>
</head>
<body>
US state name :
<input type="text" id="stateName" value="C" />
<input type="button" value="Get Details (not if alreay running)" onclick="execute(dojo.byId('stateName').value);" />
<input type="button" value="Get Details (cancel first)" onclick="execute2(dojo.byId('stateName').value);" />
<input type="button" value="Cancel" onclick="cancelExecute();" />
<br />
<br />
<div id="info" style="padding:5px; margin:5px; background-color:#eee;">
</div>
</body>
</html>
... View more
08-10-2011
09:42 AM
|
0
|
0
|
1531
|
|
POST
|
I believe the Identify results can not be used with dojo.DeferredList(...). You could look at the 'Identify' related items on the 'Web Application Templates' group on ArcGIS.com (link) that have similar behavior. There's a lot of extra stuff in the code you probably don't need, but it shows a general pattern of how this could be done.
... View more
07-13-2011
09:37 AM
|
0
|
0
|
517
|
|
POST
|
I believe ArcMap is the only client that supports multilayer caches. Check out this note in the 'Advanced options (cache type)' section of the 'Available map cache properties' Help topic: - ArcMap is the recommended client for working with a multilayer cache. Using a multilayer cache in a Web application provides little or no advantage over using a noncached map service.
... View more
02-01-2011
07:59 AM
|
0
|
0
|
602
|
|
POST
|
You should try to pass in the polygon. I believe the help says that points are most commonly used, but other geometry types are supported.
... View more
10-27-2010
03:29 PM
|
0
|
0
|
746
|
|
POST
|
Alex, it looks like you have two 'resize' events going on. I would recommend you remove the following: dojo.connect(dijit.byId('map'),'resize',resizeMap()); ...and... function resizeMap() {
//clear any existing resize timer
clearTimeout(resizeTimer);
//create new resize timer with delay of 500 milliseconds
resizeTimer = setTimeout(function () {
map.resize();
map.reposition();
}, 500);
}
... View more
10-08-2010
08:47 AM
|
0
|
0
|
1531
|
|
POST
|
Since this functionality is application specific, here's one example of how I've done it before:
var urlObject = esri.urlToObject(document.location.href);
if (urlObject.query) {
if (urlObject.query.lon && urlObject.query.lat) {
var lon = parseFloat(urlObject.query.lon);
var lat = parseFloat(urlObject.query.lat);
var initialLocation = esri.geometry.geographicToWebMercator(new esri.geometry.Point(lon, lat, new esri.SpatialReference({
wkid: 4326
})));
map.centerAndZoom(initialLocation, 14);
}
}
... View more
10-07-2010
08:33 AM
|
0
|
0
|
2118
|
|
POST
|
Alex, below is some untested code that should give you the general idea on how to manage the sub-layer visibility:
funciton Init() {
//...
var geoDocLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://gis1.co.frederick.va.us/ArcGIS/rest/services/GeoDoc/MapServer",{id:'GeoDoc'});
geoDocLayer.setVisibleLayers([1,2,13,17,20]);
map.addLayer(geoDocLayer);
//...
}
//
// Usage: toggleSubLayer('GeoDoc', 17);
//
function toggleSubLayer(layerId, subLayerId) {
var layer = map.getLayer(layerId);
if(layer && layer.visibleLayers) {
var visibleLayers = layer.visibleLayers;
var layerIndex = dojo.indexOf(visibleLayers, subLayerId);
if(layerIndex === -1) {
visibleLayers.push(subLayerId);
} else {
visibleLayers.splice(layerIndex, 1);
}
visibleLayers = (visibleLayers.length > 0) ? visibleLayers : [-1];
layer.setVisibleLayers(visibleLayers);
}
}
... View more
10-07-2010
08:16 AM
|
0
|
0
|
1531
|
|
POST
|
Alex, my guess is that there are many, many features at your current extent that are in the GeoDoc 1,2,13,17,20 layers. Every FeatureLayer in OnDemand mode basically retrieves all the features for the current extent and adds them as graphics to your map. Browsers can't handle too many graphics so you're probably requesting many features and it's just taking a long time to get them back and shown in the browser. Have you tried adding the GeoDoc map service as a DynamicMapServiceLayer and then use 'setVisibleLayers([1,2,13,17,20])' method before adding it t the map? You can still control the visibility of these sub-layers by managing the array of visible layers of the DynamicMapServiceLayer.
... View more
10-06-2010
08:29 AM
|
0
|
0
|
1531
|
|
POST
|
Tim, In that case, you could create a slightly more generic version of this function that takes a callback as a parameter and then each call to this function can do something different when the map has finished setting the new extent. Something kinda like this:
function setMapExtent(newExtent, callback) {
var onExtentChangeHandle = dojo.connect(map, 'onExtentChange', function() {
dojo.disconnect(onExtentChangeHandle);
if(callback){
callback();
}
});
map.setExtent(newExtent);
}
var graphics = [];
graphics.push(destGraphic);
graphics.push(vehGraphic);
var extent = esri.graphicsExtent(graphics);
setMapExtent(extent, function() {
map.infoWindow.hide();
map.infoWindow.setTitle(destGraphic.getTitle());
map.infoWindow.setContent(destGraphic.getContent());
map.infoWindow.resize(350, 300);
var destPoint = new esri.geometry.Point(destData.Longitude,
destData.Latitude, new esri.SpatialReference({ wkid: 4326 }));
var screenPoint = map.toScreen(destPoint);
map.infoWindow.show(screenPoint, map.getInfoWindowAnchor(screenPoint));
});
... View more
08-26-2010
08:38 AM
|
0
|
0
|
733
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-07-2024 04:14 PM | |
| 1 | 02-23-2024 12:40 PM | |
| 1 | 03-01-2024 10:48 AM | |
| 2 | 08-03-2023 02:34 PM | |
| 2 | 07-19-2023 12:05 PM |
| Online Status |
Offline
|
| Date Last Visited |
10-24-2024
06:01 PM
|