|
POST
|
There are a few issues... -your doSimplify function is never used -you don't need to pass in your polygonGraphic to doQuery since polygonGraphic is global I put together a working example using services hosted by esri: <html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dijit/themes/tundra/tundra.css">
<style>
html, body { height: 100%; width: 100%; margin: 0; padding: 0; }
</style>
<script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.6" type="text/javascript"></script>
<script type="text/javascript">
dojo.require("esri.map");
var map = null;
var gsvc = null;
var qtask = null;
var polygonGraphic = null;
var queryGraphic = null;
function initialize() {
map = new esri.Map("map");
dojo.connect(map, "onLoad", function () {
drawPolygon();
});
var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer");
map.addLayer(layer);
map.setExtent(new esri.geometry.Extent({"xmin":-115.960,"ymin":36.524,"xmax":-115.734,"ymax":36.648,"spatialReference":{"wkid":4269}}));
gsvc = new esri.tasks.GeometryService("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer");
qtask = new esri.tasks.QueryTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/0");
}
function drawPolygon() {
var polygon = {"rings":[[
[-115.930, 36.540],
[-115.740, 36.540],
[-115.740, 36.640],
[-115.930, 36.640],
[-115.930, 36.540]
]],
"spatialReference":{" wkid":4269}};
var polygon = new esri.geometry.Polygon(polygon);
var symbol = new esri.symbol.SimpleFillSymbol().setStyle(esri.symbol.SimpleFillSymbol.STYLE_SOLID);
polygonGraphic = new esri.Graphic(polygon, symbol);
map.graphics.add(polygonGraphic);
}
function doQuery() {
var query = new esri.tasks.Query();
query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS;
query.geometry = polygonGraphic.geometry;
query.returnGeometry = true;
qtask.execute(query, queryCallback);
}
function queryCallback(featureSet) {
var symbol = new esri.symbol.SimpleMarkerSymbol();
symbol.style = esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE;
symbol.setSize(8);
symbol.setColor(new dojo.Color([255,255,0,0.5]));
var features = featureSet.features;
dojo.forEach(features, function(feature) {
feature.setSymbol(symbol);
map.graphics.add(feature);
});
}
dojo.addOnLoad(initialize);
</script>
</head>
<body class="tundra">
<input type="button" value="Query for points within the polygon graphic." onclick="doQuery();" />
<div id="map" style="width:1000px; height:600px; border:1px solid #000;"></div>
</body>
</html>
... View more
08-31-2010
08:31 AM
|
0
|
0
|
1566
|
|
POST
|
There's a clustering example in this bundle of demos: http://resources.esri.com/arcgisserver/apis/javascript/arcgis/index.cfm?fa=codeGalleryDetails&scriptId=16092 This one builds on the sample included above: http://www.arcgis.com/home/item.html?id=c546bc8d4f0b4c0fbdf149b92223e681
... View more
08-30-2010
07:59 AM
|
1
|
1
|
1326
|
|
POST
|
Link works for me... I took a quick look. Where do you add your dynamic layer to the map? I see where you create it: //load basemap dynamic last so it's always on top
dn_layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://" + mapserv + ".geostor.arkansas.gov/ArcGIS/rest/services/BASEMAP_DYNAMIC/MapServer",{id:"dyn_layer"});
dyn_layer.setOpacity(".5") but I don't see where you add it to your map. Also, I can't get your dynamic layer to display from the services directory but I might be using the wrong URL: http://www.geostor.arkansas.gov/ArcGIS/rest/services/Basemap_Dynamic/MapServer?f=jsapi Finally, and this is just out of curiosity, what is the advantage to using your initLayer function rather than just creating and adding layers to your map?
... View more
08-27-2010
12:05 PM
|
0
|
0
|
1898
|
|
POST
|
If I understand you correctly, you should just pass in null. Check out the docs for dojo.declare: http://docs.dojocampus.org/dojo/declare
... View more
08-27-2010
11:48 AM
|
0
|
0
|
625
|
|
POST
|
Two samples that might be helpful: http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/util_distance.html http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/util_measureline.html
... View more
08-23-2010
10:28 AM
|
0
|
0
|
1595
|
|
POST
|
That code looks fine. I would say your problem is with your map service if nothing displays when you load your page. Are you able to view your service using the JavaScript preview from the services directory? The url should be http://servarcgisprd/arcgis/rest/services/Demo_001/MapServer?f=jsapi
... View more
08-18-2010
02:14 PM
|
0
|
0
|
864
|
|
POST
|
Can you verify that you're setting your query geometry correctly? Double-check that you're handling the result of the buffer properly.
... View more
08-13-2010
11:51 AM
|
0
|
0
|
1296
|
|
POST
|
For your second query to run successfully, you'll probably need to configure a proxy. From the sample's page: Notice that this sample references a proxy page in case the geometry of the first block group is so complex that the second query exceeds the maximum 2000 character limit that some browsers impose on GET requests. See Using the proxy page to learn more about this.
... View more
08-13-2010
11:39 AM
|
0
|
0
|
575
|
|
POST
|
Since you're now dealing with points, the simplest/quickest fix would be to use map.centerAt(mapPoint) instead of trying to zoom to an extent. Instead of: map.setExtent(taxLotExtent, true); Try: map.centerAt(selectedTaxLot.geometry);
... View more
08-12-2010
09:46 AM
|
0
|
0
|
1102
|
|
POST
|
JavaScript isn't going to be able to talk to your SQL DB directly. You'll need to use something server side to make the connection, run a query and serve out the results.
... View more
08-12-2010
09:01 AM
|
0
|
0
|
395
|
|
POST
|
Yep. You'd also want to modify the onRowClickHandler() function as it expects a polygon and not a point. You could just have the map pan to your city point or you could build an extent from the city point.
... View more
08-11-2010
12:21 PM
|
0
|
0
|
1102
|
|
POST
|
I've used Filtering Selects since v1.2 of the JS API.
... View more
08-10-2010
05:38 PM
|
0
|
0
|
1876
|
|
POST
|
Make sure you're passing a valid node ID to the filtering select constructor...if you've got a lot of code, maybe just upload it as an attachment?
... View more
08-10-2010
02:25 PM
|
0
|
0
|
1876
|
|
POST
|
I ran into this in the past and got around it by using a filtering select. Same appearance and functionality but you will also be able to get to your "hidden" values. Edit: try it out here: http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/form/_autoComplete.html?testWidget=dijit.form.FilteringSelect Run this in the firebug console: dijit.byId("setvaluetest").get('value')
dijit.byId("setvaluetest").get('displayedValue')
... View more
08-10-2010
01:26 PM
|
0
|
0
|
1876
|
|
POST
|
Try this: <!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" />
<title>Display Find Task results in Dojo DataGrid</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dijit/themes/tundra/tundra.css">
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dojox/grid/resources/Grid.css">
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dojox/grid/resources/tundraGrid.css">
<script type="text/javascript">
djConfig = {
parseOnLoad:true
}
</script>
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.6"></script>
<script type="text/javascript">
dojo.require("esri.map");
dojo.require("dojox.grid.DataGrid");
dojo.require("dojo.data.ItemFileReadStore");
dojo.require("esri.tasks.find");
var findTask, findParams;
var map, startExtent;
var grid, store;
function init() {
dojo.connect(grid, "onRowClick", onRowClickHandler);
//Create map and add the ArcGIS Online imagery layer
startExtent = new esri.geometry.Extent(-122.9, 45.3, -122.4, 45.7, new esri.SpatialReference({wkid:4326}));
map = new esri.Map("map", { extent: startExtent });
var streetMapLayer = new esri.layers.ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_Imagery_World_2D/MapServer");
map.addLayer(streetMapLayer);
//Create Find Task using the URL of the map service to search
findTask = new esri.tasks.FindTask("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Specialty/ESRI_StatesCitiesRivers_USA/MapServer");
//Create the find parameters
findParams = new esri.tasks.FindParameters();
findParams.returnGeometry = true;
findParams.layerIds = [2];
findParams.searchFields = ["STATE_NAME"];
}
function doFind() {
//Set the search text to the value in the box
findParams.searchText = dojo.byId("ownerName").value;
findTask.execute(findParams,showResults);
}
function showResults(results) {
//This function works with an array of FindResult that the task returns
map.graphics.clear();
var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_NULL, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([255,255,0]), 2), new dojo.Color([0,0,0,0]));
//Create items array to be added to store's data
var items = []; //all items to be stored in data store
for (var i=0, il=results.length; i<il; i++) {
items.push(results.feature.attributes); //append each attribute list as item in store
var graphic = results.feature;
graphic.setSymbol(symbol);
map.graphics.add(graphic);
}
//Create data object to be used in store
var data = {
identifier: "FID", //This field needs to have unique values
label: "FID", //Name field for display. Not pertinent to a grid but may be used elsewhere.
items: items
};
//Create data store and bind to grid.
store = new dojo.data.ItemFileReadStore({ data:data });
grid.setStore(store);
grid.setQuery({ 'FID': '*' });
//Zoom back to the initial map extent
map.setExtent(startExtent);
}
//Zoom to the parcel when the user clicks a row
function onRowClickHandler(evt){
var clickedTaxLotId = grid.getItem(evt.rowIndex).FID;
var selectedTaxLot;
for (var i=0, il=map.graphics.graphics.length; i<il; i++) {
var currentGraphic = map.graphics.graphics;
if ((currentGraphic.attributes) && currentGraphic.attributes.FID == clickedTaxLotId){
selectedTaxLot = currentGraphic;
break;
}
}
var taxLotExtent = selectedTaxLot.geometry.getExtent();
map.setExtent(taxLotExtent, true);
}
dojo.addOnLoad(init);
</script>
</head>
<body class="tundra">
Owner name: <input type="text" id="ownerName" size="60" value="Indiana" />
<input type="button" value="Search" onclick="doFind();" /><br />
<br />
<div id="map" style="width:600px; height:300px; border:1px solid #000;"></div>
<table dojoType="dojox.grid.DataGrid" jsid="grid" id="grid" rowsPerPage="5" rowSelector="20px" style="height:300px; width:600px">
<thead>
<tr>
<th field="FID">Feature ID</th>
<th field="STATE_NAME">State Name</th>
<th field="MALES">Males</th>
<th field="FEMALES">Females</th>
</tr>
</thead>
</table>
</body>
</html> I didn't change much besides the map service used by the find task. You were on the right track for replacing "TLID" with "FID." Edit: If you're just starting out, go with version 2 of the API: http://help.arcgis.com/en/webapi/javascript/arcgis/
... View more
08-09-2010
07:03 PM
|
0
|
0
|
1102
|
| 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
|