|
POST
|
Glad to hear that. Please don't forget to click the check mark to signify your question was answered.
... View more
10-23-2013
09:20 AM
|
0
|
0
|
840
|
|
POST
|
IEnvelope has a Union method. You can loop through all the features and union their extents. See this post as an example
... View more
10-23-2013
07:38 AM
|
0
|
0
|
840
|
|
POST
|
The xyToLngLat method will only correctly convert input coordinates in Web Mercator to WGS84. To convert coordinates in any other projection, you'll have to use a Geometry Service. Here's a modification of the Project a Point sample that uses the WKID 3021
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!--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>Project a point</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>
.esriPopup .contentPane span {
display: inline-block;
padding: 0 0 0.2em 0;
width: 6em;
}
</style>
<script src="http://js.arcgis.com/3.7/"></script>
<script>
var map, gsvc, pt;
require([
"esri/map", "esri/graphic", "esri/symbols/SimpleMarkerSymbol",
"esri/tasks/GeometryService", "esri/tasks/ProjectParameters",
"esri/SpatialReference", "esri/InfoTemplate", "dojo/dom", "dojo/on",
"dojo/domReady!"
], function(
Map, Graphic, SimpleMarkerSymbol,
GeometryService, ProjectParameters,
SpatialReference, InfoTemplate, dom, on
) {
map = new Map("map", {
basemap: "streets",
center: [-98.445, 46.147],
zoom: 3
});
gsvc = new GeometryService("http://tasks.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
map.on("click", projectToWebMercator);
function projectToWebMercator(evt) {
map.graphics.clear();
var point = evt.mapPoint;
var symbol = new SimpleMarkerSymbol().setStyle("diamond");
var graphic = new Graphic(point, symbol);
var outSR = new SpatialReference(102100);
map.graphics.add(graphic);
gsvc.project([ point ], outSR, function(projectedPoints) {
pt = projectedPoints[0];
graphic.setInfoTemplate(new InfoTemplate("Coordinates",
"<span>X:</span>" + pt.x.toFixed() + "<br>" +
"<span>Y:</span>" + pt.y.toFixed() + "<br>" +
"<input type='button' value='Convert back to LatLong' id='convert'>" +
"<div id='latlong'></div>"+
"<input type='button' value='Convert to RT90' id='convertRT'>" +
"<div id='rt90'></div>"));
map.infoWindow.setTitle(graphic.getTitle());
map.infoWindow.setContent(graphic.getContent())
map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));
on.once(dom.byId("convert"), "click", projectToLatLong);
on.once(dom.byId("convertRT"), "click", projectToRT90);
});
}
function projectToLatLong() {
var outSR = new SpatialReference(4326);
var params = new ProjectParameters();
params.geometries = [pt];
params.outSR = outSR;
gsvc.project(params, function(projectedPoints) {
pt = projectedPoints[0];
dom.byId("latlong").innerHTML = "<span>Latitude: </span> " +
pt.y.toFixed(3) + "<br><span>Longitude:</span>" + pt.x.toFixed(3);
});
}
function projectToRT90() {
var outSR = new SpatialReference(3021);
var params = new ProjectParameters();
params.geometries = [pt];
params.outSR = outSR;
gsvc.project(params, function(projectedPoints) {
pt = projectedPoints[0];
dom.byId("rt90").innerHTML = "<span>X: </span> " +
pt.y.toFixed(3) + "<br><span>Y:</span>" + pt.x.toFixed(3);
});
}
});
</script>
</head>
<body class="claro">
<b>Click a location on the map to Project from LatLng -> Web Mercator:</b>
<div id="map" style="width:600px; height:400px; border:1px solid #000;"></div>
</body>
</html>
... View more
10-22-2013
04:24 AM
|
0
|
0
|
1397
|
|
POST
|
This subject is a little hard to find in the documentation. It's found in the Delay Loading section of this topic.
... View more
10-10-2013
11:59 AM
|
0
|
0
|
3317
|
|
POST
|
There is a new version of the TOC tool that has the ability to collapse nodes. This is the latest version.
... View more
10-07-2013
07:17 AM
|
0
|
0
|
2511
|
|
POST
|
You should mark your own post as the correct answer to help users who may be searching on this question.
... View more
10-04-2013
11:54 AM
|
0
|
0
|
1238
|
|
POST
|
Just combine the code from your two functions into a single function. map.on("layers-add-result", layersAddResultHandler); function layersAddResultHandler(evt) { //initEditing code console.log("initEditing", evt); // var map = this; var currentLayer = null; var layers = arrayUtils.map(evt.layers, function(result) { return result.layer; }); console.log("layers", layers); //etc //initSelectToolbar code var stewardship = evt.layers[0].layer; var selectQuery = new Query(); //etc. }
... View more
10-04-2013
08:51 AM
|
0
|
0
|
740
|
|
POST
|
Take a look at this page on setting up a development environment. When developing with the ArcGIS API for JavaScript, a web server is required. This means that web pages and apps using the ArcGIS API for JavaScript need to be accessed over http:// (or https://) rather than file://. To meet this requirement, install and configure a web server. Web server software is available free of charge for all operating systems.
... View more
10-02-2013
10:46 AM
|
0
|
0
|
1023
|
|
POST
|
Your require modules and function arguments aren't agreeing
require([
"dojo/parser","esri/config", "esri/map", "esri/dijit/InfoWindow", "esri/dijit/Popup","esri/SpatialReference", "esri/geometry/Extent",
"esri/layers/ArcGISDynamicMapServiceLayer", "esri/layers/GraphicsLayer",
"esri/dijit/BasemapGallery","agsjs/dijit/TOC","esri/tasks/IdentifyTask", "esri/tasks/IdentifyParameters", "esri/InfoTemplate", "esri/tasks/QueryTask",
"esri/tasks/query", "esri/tasks/GeometryService","dojo/_base/array", "dojo/_base/connect", "dojo/on", "dojo/dom","dijit/registry", "dojo/promise/all","esri/symbols/SimpleMarkerSymbol",
"esri/symbols/SimpleFillSymbol", "esri/symbols/SimpleLineSymbol", "dojo/_base/Color", "dijit/layout/BorderContainer", "dijit/layout/ContentPane",
"dijit/TitlePane", "dijit/form/Select", "dgrid/Grid", "esri/graphic", "dojo/domReady!"
], function(
parser, esriConfig, Map, InfoWindow, Popup, SpatialReference, Extent, ArcGISDynamicMapServiceLayer, GraphicsLayer, BasemapGallery, TOC, IdentifyTask, IdentifyParameters,
InfoTemplate, QueryTask, Query, GeometryService, arrayUtils, connect, on, dom, registry, all, SimpleMarkerSymbol,
SimpleFillSymbol, SimpleLineSymbol, Color, BorderContainer, ContentPane, TitlePane, Select, Grid, Graphic) {
... View more
09-27-2013
09:50 AM
|
0
|
0
|
1463
|
|
POST
|
In my application, when I get the results from my IdentifyTask, I put the returned graphics onto a graphics layer (layerResultsGraphic). I have two functions to highlight a row. When the user mouses over the dGrid row, the feature gets highlighted. When the user clicks on the row, the feature gets flashed.
function findGraphicByAttribute(attributes) {
for (i = 0; i < layerResultsGraphic.graphics.length; i++) {
if (JSON.stringify(layerResultsGraphic.graphics.attributes) === JSON.stringify(attributes)) { return layerResultsGraphic.graphics; }
}
return null;
}
//this function will highlight the selected feature
function gridEnter(e) {
map.graphics.clear();
var gridId = e.currentTarget.id;
var selectedGrid = dijit.byId(gridId);
var row = selectedGrid.row(e);
graphicHighlight = findGraphicByAttribute(row.data);
if (graphicHighlight !== null) {
switch (graphicHighlight.geometry.type) {
case "point": case "multipoint":
map.graphics.add(new esri.Graphic(graphicHighlight.geometry, symbolHighlightPoint));
break;
case "polyline":
map.graphics.add(new esri.Graphic(graphicHighlight.geometry, symbolHighlightPolyline));
break;
case "polygon": case "extent":
map.graphics.add(new esri.Graphic(graphicHighlight.geometry, symbolHighlightPolygon));
break;
}
}
}
//this function will "flash" the selected feature
function gridSelect(e) {
var graphicFlash;
var gridId = e.currentTarget.id;
var selectedGrid = dijit.byId(gridId);
var row = selectedGrid.row(e);
graphicHighlight = findGraphicByAttribute(row.data);
if (graphicHighlight !== null) {
switch (graphicHighlight.geometry.type) {
case "point": case "multipoint":
graphicFlash = new esri.Graphic(graphicHighlight.geometry, symbolFlashPoint)
break;
case "polyline":
graphicFlash = new esri.Graphic(graphicHighlight.geometry, symbolFlashPolyline);
break;
case "polygon": case "extent":
graphicFlash = new esri.Graphic(graphicHighlight.geometry, symbolFlashPolygon);
break;
}
map.graphics.add(graphicFlash);
}
var shape = graphicFlash.getDojoShape();
var animStroke = fx.animateStroke({
shape: shape,
duration: 500,
color: { end: new dojo.Color([0, 0, 0, 0]) }
});
var animFill = fx.animateFill({
shape: shape,
duration: 500,
color: { end: new dojo.Color([0, 0, 0, 0]) }
});
var anim = dojo.fx.combine([animStroke, animFill]).play();
var animConnect = dojo.connect(anim, "onEnd", function () {
map.graphics.remove(graphicFlash);
});
}
... View more
09-27-2013
08:24 AM
|
0
|
0
|
1463
|
|
POST
|
Do you also need to set the columns property of the dgrid? I'm using the dgrid to hold the contents of an IdentifyTask. This will be for a variety of layers, so I'm not hard coding the column list, which will show all the fields except the Shape field. This also adds the dgrid to a ContentPane and sets up some events.
var columns = buildColumns(results[0].feature); //builds the column list from the first feature
var features = [];
for (i = 0, len = results.length; i < len; i++) {
features.push(results.feature);
}
var data = array.map(features, function (feature) {
return lang.clone(feature.attributes);
});
var dataGrid = new (declare([Grid, Selection, DijitRegistry, ColumnHider]))({
id: "dgrid_0",
bufferRows: Infinity,
columns: columns,
selectionMode: "single",
"class": "resultsGrid"
});
var gridWidth = "width: " + String(columns.length * 100) + "px";
dataGrid.addCssRule("#" + dataGrid.id, gridWidth); //this makes the dgrid large enough to show all the columns
dataGrid.on(".dgrid-row:click", gridSelect); //this flashes the feature
dataGrid.on("show", function () {
dataGrid.resize();
});
dataGrid.on(mouseUtil.enterRow, gridEnter); //this highlights the feature
dataGrid.on(mouseUtil.leaveRow, function () {
map.graphics.clear();
});
var plural = "";
if (combineResults[result].length !== 1) { plural = "s"; }
var cp = new dijit.layout.ContentPane({
id: result,
content: "<strong>" + combineResults[result][0].layerName + "</strong> (" + combineResults[result].length + " feature" + plural + ")",
title: combineResults[result][0].layerId,
style: "overflow: auto"
}).placeAt(dijit.byId('tabs'));
cp.addChild(dataGrid);
cp.startup();
dataGrid.renderArray(data);
function buildColumns(feature) {
var attributes = feature.attributes;
var columns = [];
for (var attribute in attributes) {
if (attributes.hasOwnProperty(attribute)) {
var objects = {};
objects.label = attribute;
objects.field = attribute;
if (attribute === "Shape") {
objects.hidden = true;
}
columns.push(objects);
}
}
return columns;
}
This is part of an application to show the results from different layers in a service in one Tab Container contain a dgrid for each layer. Here's a Fiddle that shows it in action.
... View more
09-26-2013
08:39 AM
|
0
|
0
|
1749
|
|
POST
|
You should also take a look at this tutorial to get a better understanding of the new coding concepts. While some of the changes are fundamental and at first glance might be confusing, they are all there for good reasons to make your code be more efficient, run faster, better leverage JavaScript and make your code more maintainable.
... View more
09-25-2013
06:11 AM
|
0
|
0
|
1890
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-04-2025 06:39 AM | |
| 1 | 05-01-2026 08:26 AM | |
| 1 | 04-10-2026 12:01 PM | |
| 1 | 04-13-2026 09:11 AM | |
| 1 | 10-11-2023 06:18 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|