POST
|
HI, Please help me regarding below code. I want to display Query Info without Map. I copied this code from js sample code and i changed queryTask url and outFields name. But this is not working.. why? Please guide me. Thanks RG <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Query Info without Map</title>
<link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/2.1/js/dojo/dijit/themes/claro/claro.css">
<script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.1"></script>
<script type="text/javascript" language="Javascript">
dojo.require("esri.tasks.query");
dojo.require("esri.map");
var queryTask, query;
function init() {
//build query
queryTask = new esri.tasks.QueryTask("http://localhost:8399/arcgis/rest/services/future_india/MapServer/6");
//dojo.connect(queryTask, "onComplete", showResults);
//build query filter
query = new esri.tasks.Query();
query.returnGeometry = false;
query.outFields = ["Lat", "Longs", "LocAddress"];
}
function execute(stateName) {
query.text = stateName;
queryTask.execute(query,showResults);
}
function showResults(results) {
alert("showResults");
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>
name : <input type="text" id="stateName" value="Bhiwandi" />
<input type="button" value="Get Details" onclick="execute(dojo.byId('stateName').value);" />
<br />
<br />
<div id="info" style="padding:5px; margin:5px; background-color:#eee;">
</div>
</body>
</html>
... View more
02-01-2011
02:30 AM
|
0
|
1
|
517
|
POST
|
Hello All, I want to refresh point geometry symbol without refreshing Map. For example:- When new data(Lat-Long) coming from the database, it will show the current point position on map without refreshing page or map. Please, anybody help me. Regards, RG
... View more
01-07-2011
11:51 PM
|
0
|
1
|
548
|
POST
|
Hello Rachel , Can you please me the code. It willl easy to find out the problem. Example for Extent :- var initExtent = new esri.geometry.Extent({"xmin":-17731,"ymin":6710077,"xmax":-12495,"ymax":6712279,"spatialReference":{"wkid":102100}});
map = new esri.Map("map",{extent:initExtent});
Regards, Rohit Garg Hi Rohit, Thanks for your help. The code works fine. But I changed the both ArcGISDynamicMapServiceLayers to my own map services. For once the code loaded both layers well, but I changed the map extents for both maps, it cannot display the map unless I paned the map. Any ideas? Rachel
... View more
09-29-2010
09:55 AM
|
0
|
0
|
330
|
POST
|
Hello Rachel, You can also check this link:- http://resources.esri.com/help/9.3/arcgisserver/apis/javascript/arcgis/help/jshelp/videos/sample_extend.htm Regards, Rohit Garg Hello Rachel, Your code is perfect and working fine. Due to connection issues it will take time to load... wait for 2-3 mins maybe it is taking time to load the map services. Regards, Rohit Garg
... View more
09-28-2010
10:24 PM
|
0
|
0
|
330
|
POST
|
Hello Rachel, Your code is perfect and working fine. Due to connection issues it will take time to load... wait for 2-3 mins maybe it is taking time to load the map services. Regards, Rohit Garg Hello, I used the following sample code to load my tiled base map layer and my dynamic map layer. Both map server have the same projection and same display extents. When the map initially loaded I cannot see both layers and when I pan a little bit, the layers displayed. Can you help me to fix this problem? Thank you, Rachel ******** <!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>Create Map</title> <link rel="stylesheet" type="text/css" href="http://serverapi.arcgisonline.com/jsapi/arcgis/1.6/js/dojo/dijit/themes/tundra/tundra.css"> <script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.6"></script> <script type="text/javascript"> dojo.require("esri.map"); function init() { var map = new esri.Map("map"); //Takes a URL to a non cached map service. var dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Petroleum/KGS_OilGasFields_Kansas/MapServer"); map.addLayer(dynamicMapServiceLayer); var dynlayer2 = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer",{"opacity":0.5}); map.addLayer(dynlayer2); } dojo.addOnLoad(init); </script> </head> <body class="tundra"> <div id="map" style="width:900px; height:600px; border:1px solid #000;"></div> Creates a map and adds an ArcGISDynamicMapServiceLayer.<br /> Map navigation using mouse: <ul> <li>Drag to pan</li> <li>SHIFT + Click to recenter</li> <li>SHIFT + Drag to zoom in</li> <li>SHIFT + CTRL + Drag to zoom out</li> <li>Mouse Scroll Forward to zoom in</li> <li>Mouse Scroll Backward to zoom out</li> <li>Use Arrow keys to pan</li> <li>+ key to zoom in a level</li> <li>- key to zoom out a level</li> <li>Double Click to Center and Zoom in</li> </ul> </body> </html> ***
... View more
09-28-2010
10:15 PM
|
0
|
0
|
330
|
POST
|
Hello, I have 2 polygon, I want to select those point which is under Polygon 2. Is it possible ? Below is the code shows 2 polygons and selecting all points(under polygon 1 and polygon 2). <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 polygonGraphic2 = null; var queryGraphic = null; var extent = null; function initialize() { map = new esri.Map("map"); dojo.connect(map, "onLoad", function () { drawPolygon(); drawPolygon2(); }); var layer = new esri.layers.ArcGISDynamicMapServiceLayer("http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer"); map.addLayer(layer); extent = 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_NULL); polygonGraphic = new esri.Graphic(polygon, symbol); map.graphics.add(polygonGraphic); } function drawPolygon2() { var polygon2 = {"rings":[[ [-115.950, 36.520], [-115.740, 36.520], [-115.740, 36.650], [-115.950, 36.650], [-115.950, 36.520] ]], "spatialReference":{" wkid":4269}}; var polygon2 = new esri.geometry.Polygon(polygon2); var symbol2 = new esri.symbol.SimpleFillSymbol().setStyle(esri.symbol.SimpleFillSymbol.STYLE_CROSS); polygonGraphic2 = new esri.Graphic(polygon2, symbol2); map.graphics.add(polygonGraphic2); } function doQuery() { var query = new esri.tasks.Query(); query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS; query.geometry = polygonGraphic2.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(15); 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
09-02-2010
04:14 AM
|
0
|
0
|
384
|
POST
|
Hello All, I have 2 polygon. I want to do Erase function. Is it possible. If yes please let me know. Regards, RG
... View more
09-02-2010
04:10 AM
|
0
|
1
|
507
|
POST
|
Hello Derek, Below is my code :- <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/PublicSafety/PublicSafetyBasemap/MapServer/"); map.addLayer(layer); map.setExtent(new esri.geometry.Extent({"xmin":-85.96,"ymin":37.985,"xmax":-85.385,"ymax":38.393,"spatialReference":{"wkid":4326}})); 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/PublicSafety/PublicSafetyBasemap/MapServer/12"); } function drawPolygon() { var polygon = {"rings":[[ [-85.950, 38.000], [-85.0, 37.9], [-85.440, 38.540], [-85.740, 38.640], [-85.930, 38.640], [-85.950, 38.000] ]], "spatialReference":{" wkid":4326}}; 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_TOUCHES; query.geometry = polygonGraphic.geometry; query.returnGeometry = true; qtask.execute(query, queryCallback); alert("hidoQ"); } function queryCallback(featureSet) { var symbol = new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([0,0,0]), 5); var features = featureSet.features; alert("1"); dojo.forEach(features, function(feature){feature.setSymbol(symbol); map.graphics.add(features); alert("5"); }); } 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:800px; height:400px; border:1px solid #000;"></div> </body> </html> What is the error message?
... View more
09-01-2010
09:22 PM
|
0
|
0
|
384
|
POST
|
What is the error message? Thanks for the reply... I want show error alert, if polyline touches/crossess polygon, it should throw some error like "polyline cross the line" with line name.
... View more
09-01-2010
09:29 AM
|
0
|
0
|
384
|
POST
|
Hello Derek, I have a one query. Like I have one polygon and one Polyline, If Polyline cross Polygon then it will through error alert message. Can you please help me. Regards, RG email:-rohitgarg83@gmail.com
... View more
09-01-2010
02:04 AM
|
0
|
0
|
384
|
POST
|
Thanks Derek, Great... now its working fine in my application. 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
09-01-2010
01:47 AM
|
0
|
0
|
384
|
POST
|
Hello All, I have created polygon, now i want to select points under polygon on click... please help me.. this is my code:- [HTML] <script src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=1.6" type="text/javascript"></script> <script type="text/javascript"> dojo.require("esri.map"); dojo.require("esri.tasks.geometry"); dojo.require("esri.geometry"); 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://myserver:8399/arcgis/rest/services/Data_Demo/MapServer/"); map.addLayer(layer); map.setExtent(new esri.geometry.Extent(72.81, 18.95, 72.85, 18.98, new esri.SpatialReference({wkid: 4326}))); gsvc = new esri.tasks.GeometryService("http://myserver:8399/arcgis/rest/services/Geometry/GeometryServer"); qtask = new esri.tasks.QueryTask("http://myserver:8399/arcgis/rest/services/Data_Demo/MapServer/2"); } function drawPolygon() { var latOffset, lonOffset, center, lat, lon, points; center = map.extent.getCenter(); var Lat = 76.85; var Lon = 26.298; var Lat1= 72.8296; var Lng1= 18.99522; var Lat2= 72.819175; var Lng2= 18.970838; var Lat3= 72.828; var Lng3= 18.969; var Lat4= 72.832; var Lng4= 18.951; var Lat5= 72.823697;var Lng5= 18.946847; var Lat6= 72.826775035; var Lng6= 18.93383939; var Lat7 = 72.8150861175; var Lng7 = 18.96397220334;var Lat8 = 72.81860278088;var Lng8 = 18.951649999; var polygon = {"rings":[[[Lat1,Lng1],[Lat3,Lng3],[Lat6,Lng6], [Lat5,Lng5],[Lat8,Lng8],[Lat7,Lng7], [Lat2,Lng2], [Lat1,Lng1]]], "spatialReference":{" wkid":4326 }}; 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 doSimplify() { gsvc.simplify([ polygonGraphic.geometry ], doQuery(polygonGraphic)); } function doQuery(polygonGraphic) { var query = new esri.tasks.Query(); //query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_INTERSECTS; query.spatialRelationship = esri.tasks.Query.SPATIAL_REL_CONTAINS; query.geometry = polygonGraphic.geometry; query.returnGeometry = true; qtask.execute(query, queryCallback); } function queryCallback(featureSet) { map.graphics.remove(queryGraphic); 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; var point = new esri.geometry.Point(); queryGraphic = new esri.Graphic(point,symbol) map.graphics.add(queryGraphic); } dojo.addOnLoad(initialize); </script> </head> <body class="tundra"> <input type="button" value="Simplify the polygon and Do a Query with simplified polygon" onclick="doQuery(polygonGraphic);" /> <div id="map" style="width:600px; height:400px; border:1px solid #000;"></div> </body> </HTML>
... View more
08-31-2010
03:15 AM
|
0
|
7
|
2221
|
POST
|
Is there any example usses this :- esri.tasks.Query.SPATIAL_REL_CROSSES
... View more
08-30-2010
01:40 AM
|
0
|
0
|
473
|
POST
|
Hello All, I want to create topology rules using arcgis server javascript. I want to use it in Web Application. Can anybody have idea about this. Thanks, RG
... View more
08-20-2010
02:47 AM
|
1
|
1
|
836
|
Title | Kudos | Posted |
---|---|---|
1 | 08-20-2010 02:47 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|