POST
|
Did you in the end found a solution? I would be very interested to see it since i'm running into the same problem Hi Derek I am experiencing the same problem with my graphic layer on the print pdf map. When graphics added to the map, the print widget doesn't work, when I clear the graphic layer, the print widgets works printing all the other dynamic layer legends. The error I get from Json response, when I add the graphic layer to map is {"error":{"code":400, "message":"unable to complete operation.", "details":["Error exectuing tool.: Layer\"_exploreKentGraphicsLayerId\": Unsupported 'type' in symbol: esriCLS.\nLayer\"_exploreKentGraphicsLayerId\nFailed to execute (Export Web Map Task). Can you please let me know, how to resolve this. Regards Ganesh
... View more
06-04-2014
07:42 AM
|
0
|
0
|
304
|
POST
|
Ganesh, What you are looking for is snapping. SnappingManager provides exact the same as you described. https://developers.arcgis.com/javascript/jsapi/snappingmanager-amd.html#getsnappingpoint HI Guys I found the answer finding all the points in a polyline and getting their distance and here is the code below. If anyone need this, can you use them to suit their needs. // ********************************************************************
// Gets the distance from user's location for my nearest feature types.
//
// Parameters:
// -----------
// featureGeometryType - the type of feature.
// feature - the feature itself.
// location - the location parameter for my nearest service.
// ********************************************************************
function GetDistance(featureGeometryType, feature, location)
{
try
{
var x = GetXFromLocationParameter(location);
var y = GetYFromLocationParameter(location);
var startPoint = new esri.geometry.Point(x, y, _map.spatialReference);
// alert(startPoint.x + "," + startPoint.y);
var endPoint;
switch (featureGeometryType)
{
case "esriGeometryPoint":
endPoint = new esri.geometry.Point(feature.geometry.x, feature.geometry.y, _map.spatialReference);
break;
case "esriGeometryPolygon":
var polygonJson = { "rings": feature.geometry.rings, "spatialReference": _map.spatialReference };
var myPolygon = new esri.geometry.Polygon(polygonJson);
var polyExtent = myPolygon.getExtent();
endPoint = polyExtent.getCenter();
break;
case "esriGeometryPolyline":
var polylineJson = { "paths": feature.geometry.paths, "spatialReference": _map.spatialReference };
// alert(feature.attributes.ROUTE_NAME + "<br/>" + feature.geometry.paths.length.toString() + "," + feature.geometry.paths.toString());
//For each path...
var pointArray =[];
var nearestPoint = null;
var nearestDistance = 1000;
for ( var path = 0; path < feature.geometry.paths.length; path ++ ) {
//For each point in the path...
for ( var pt = 0; pt < feature.geometry.paths[path].length; pt++ ) {
//Do something with each point in here...
//X coordinate: geo.paths[path][pt][0]
//Y coordinate: geo.paths[path][pt][1]
// alert(feature.geometry.paths[path][pt][0] + "," + feature.geometry.paths[path][pt][1]);
var linex = feature.geometry.paths[path][pt][0];
var liney = feature.geometry.paths[path][pt][1];
var linedistance = GetLinePoint2PointDistance(startPoint, linex, liney);
if (linedistance < nearestDistance)
{
nearestPoint = new esri.geometry.Point(linex, liney, _map.spatialReference);
nearestDistance = linedistance;
}
// alert(linedistance);
// pointArray.push(linedistance);
// alert(nearestPoint.x + ", " + nearestPoint.y + ", " + nearestDistance);
// pointArray.sort(function(a,b) {return a-b});
// pointArray.push(feature.geometry.paths[path][pt][0],feature.geometry.paths[path][pt][1]);
console.log(pointArray);
}
//alert(nearestPoint.x + ", " + nearestPoint.y + ", " + nearestDistance);
}
// alert( feature.attributes.ROUTE_NAME + "," + nearestPoint.x + ", " + nearestPoint.y + ", " + nearestDistance);
// alert(feature.attributes.ROUTE_NAME + ", " + pointArray[0]);
var myLine = new esri.geometry.Polyline(polylineJson);
var lineExtent = myLine.getExtent();
// endPoint = lineExtent.getCenter();
endPoint = nearestPoint;
break;
}
return GetPoint2PointDistance(startPoint, endPoint);
}
catch(ex)
{
C_HandleError(ex, "method GetDistance of search.js");
}
}
// Returns the distance from the points in the polyline to the address point.
function GetLinePoint2PointDistance(startPoint, linex, liney)
{
try
{
var distanceInMetres;
var distanceInMiles;
distanceInMetres = Math.pow((linex - startPoint.x), 2) + Math.pow((liney - startPoint.y), 2);
distanceInMetres = Math.sqrt(distanceInMetres);
// Convert to miles.
distanceInMiles = distanceInMetres * 0.00062137119;
distanceInMiles = FormatNearestNumber(distanceInMiles);
return distanceInMiles;
}
catch(ex)
{
C_HandleError(ex, "method GetLinePoint2PointDistance of search.js");
}
}
// Returns the distance from passed in point to the address point.
function GetPoint2PointDistance(startPoint, endPoint)
{
try
{
var distanceInMetres;
var distanceInMiles;
distanceInMetres = Math.pow((endPoint.x - startPoint.x), 2) + Math.pow((endPoint.y - startPoint.y), 2);
distanceInMetres = Math.sqrt(distanceInMetres);
// Convert to miles.
distanceInMiles = distanceInMetres * 0.00062137119;
distanceInMiles = FormatNearestNumber(distanceInMiles);
return distanceInMiles;
}
catch(ex)
{
C_HandleError(ex, "method GetPoint2PointDistance of search.js");
}
}
... View more
05-12-2014
01:02 AM
|
0
|
0
|
1544
|
POST
|
Hi Derek, Thank you very much for looking at this thread and providing the clue to figure out. However, I figured out the answer to find the nearest point of a polyline by looping all the polyline linesegment or paths. I will post my working code tomorrow, so that it will help someone to use the code. Once again, thanks for your help. We don't have a method that returns all points from a polyline. You'll have to loop through polyline.paths and look at points from there.
... View more
03-26-2014
11:27 AM
|
0
|
0
|
1544
|
POST
|
HI Guys, In continuation of the above thread, I have a sample which was done using Microsoft Bing maps, where the user could get all the points of the line using poly.getLocations() method. Is there similar method in arcgis javascript api. Can anyone let me know, please. http://social.msdn.microsoft.com/Forums/en-US/5293337c-52f3-4635-87f9-de1beddc8e10/given-a-point-and-a-polyline-how-can-i-determine-the-closest-point-on-the-polyline?forum=bingmaps Hi Guys, I wanted to find the nearest point in the polyline from an input location and calculate its distance. At the moment, the application queries based on centroid of a polyline. In my case, I wanted to find all the points in the polyline and then push those points in an array and find the nearest point in the polyline from an input location. Here is my current code below: All I wanted to do is change the code when esri Geometry is polyline and try find all points in the feature. Can anybody help me on this please.
function GetDistance(featureGeometryType, feature, location)
{
try
{
var x = GetXFromLocationParameter(location);
var y = GetYFromLocationParameter(location);
var startPoint = new esri.geometry.Point(x, y, _map.spatialReference);
var endPoint;
switch (featureGeometryType)
{
case "esriGeometryPoint":
endPoint = new esri.geometry.Point(feature.geometry.x, feature.geometry.y, _map.spatialReference);
break;
case "esriGeometryPolygon":
var polygonJson = { "rings": feature.geometry.rings, "spatialReference": _map.spatialReference };
var myPolygon = new esri.geometry.Polygon(polygonJson);
var polyExtent = myPolygon.getExtent();
endPoint = polyExtent.getCenter();
break;
case "esriGeometryPolyline":
var polylineJson = { "paths": feature.geometry.paths, "spatialReference": _map.spatialReference };
var myLine = new esri.geometry.Polyline(polylineJson);
var lineExtent = myLine.getExtent();
endPoint = lineExtent.getCenter();
break;
}
return GetPoint2PointDistance(startPoint, endPoint);
}
catch(ex)
{
HandleError(ex, "method GetDistance of search.js");
}
}
// Returns the distance from passed in point to the address point.
function GetPoint2PointDistance(startPoint, endPoint)
{
try
{
var distanceInMetres;
var distanceInMiles;
distanceInMetres = Math.pow((endPoint.x - startPoint.x), 2) + Math.pow((endPoint.y - startPoint.y), 2);
distanceInMetres = Math.sqrt(distanceInMetres);
// Convert to miles.
distanceInMiles = distanceInMetres * 0.00062137119;
distanceInMiles = FormatNearestNumber(distanceInMiles);
return distanceInMiles;
}
catch(ex)
{
HandleError(ex, "method GetPoint2PointDistance of search.js");
}
}
... View more
03-24-2014
06:50 AM
|
0
|
0
|
1544
|
POST
|
Hi Guys, I wanted to find the nearest point in the polyline from an input location and calculate its distance. At the moment, the application queries based on centroid of a polyline. In my case, I wanted to find all the points in the polyline and then push those points in an array and find the nearest point in the polyline from an input location. Here is my current code below: All I wanted to do is change the code when esri Geometry is polyline and try find all points in the feature. Can anybody help me on this please.
function GetDistance(featureGeometryType, feature, location)
{
try
{
var x = GetXFromLocationParameter(location);
var y = GetYFromLocationParameter(location);
var startPoint = new esri.geometry.Point(x, y, _map.spatialReference);
var endPoint;
switch (featureGeometryType)
{
case "esriGeometryPoint":
endPoint = new esri.geometry.Point(feature.geometry.x, feature.geometry.y, _map.spatialReference);
break;
case "esriGeometryPolygon":
var polygonJson = { "rings": feature.geometry.rings, "spatialReference": _map.spatialReference };
var myPolygon = new esri.geometry.Polygon(polygonJson);
var polyExtent = myPolygon.getExtent();
endPoint = polyExtent.getCenter();
break;
case "esriGeometryPolyline":
var polylineJson = { "paths": feature.geometry.paths, "spatialReference": _map.spatialReference };
var myLine = new esri.geometry.Polyline(polylineJson);
var lineExtent = myLine.getExtent();
endPoint = lineExtent.getCenter();
break;
}
return GetPoint2PointDistance(startPoint, endPoint);
}
catch(ex)
{
HandleError(ex, "method GetDistance of search.js");
}
}
// Returns the distance from passed in point to the address point.
function GetPoint2PointDistance(startPoint, endPoint)
{
try
{
var distanceInMetres;
var distanceInMiles;
distanceInMetres = Math.pow((endPoint.x - startPoint.x), 2) + Math.pow((endPoint.y - startPoint.y), 2);
distanceInMetres = Math.sqrt(distanceInMetres);
// Convert to miles.
distanceInMiles = distanceInMetres * 0.00062137119;
distanceInMiles = FormatNearestNumber(distanceInMiles);
return distanceInMiles;
}
catch(ex)
{
HandleError(ex, "method GetPoint2PointDistance of search.js");
}
}
... View more
03-24-2014
06:44 AM
|
0
|
5
|
6652
|
POST
|
Hi James Thank you once again for your support. I have created my AGOL account and logged on to your application to see how it works. It was really good. If I want to use the Spatial analysis service within AGOL where should I look within account to create an application similar to the one you created. Not sure exactly where to look for the spatial anlaysis service within AGOL? Any help would be much helpful. Regards Ganesh
... View more
03-19-2014
02:35 PM
|
0
|
0
|
379
|
POST
|
Hi Guys I have solved geoprocessing problem i have with my model. Actually, When I publish the model alone as a geprocessing service, it reports that the near layer data are not found. When I include the model in the Arcmap mxd document and published them as a geoprocessing service with result map service, the model tries to work and it could get the results for my near features in the rest end point. To be honest, I really don't know why the model works when it is published as a geoprocessing with result map service and why it doesn't work when it is published just a model and basically, it is mystery. Now, my next step is to integrate my geoprocessing result map service into web application to see how it works. I have to write my javascript code and it is a real challenge here to see how it works. Regards Ganesh Hi Guys, I have built my Geoprocessing model to find nearest feature from the input location in model builder and published them as a geoprocessing service. The model works perfectly well in ARCGIS desktop. when I published them as a geoprocessing service, and tested the service with REST end points in arcgis server using submit Job Operation, I got the following error. Basically, the error reports that NearFeature layers doesn't exist, but in reality it does exist in the map and it has hard coded and the second issue is the output datasets -from the geoprocessing service reports that the data already exist. Actually, I have checked the Overwrite Outputs of geoprocessing operations in Arccatalog and ArcMap before building the model. The model overwrites output datasets and finds all near feature layers when it is run from Arcmap. However, when it is run from REST end points, it causes errors saying data already exist or not found. Have anyone come across this issue when publishing them as a geoprocessing service. Anyhelp would be much appreciated. [HTML]Job Details: Model Check Job Details: Return Messages: True False View In: Google Earth Job ID: j4b4f0182872145a093f614736caf1486 Job Status: esriJobFailed Job Messages: esriJobMessageTypeInformative: Submitted. esriJobMessageTypeInformative: Executing... esriJobMessageTypeInformative: esriJobMessageTypeWarning: WARNING 000725: KCC_InputFeature_GenerateNea8: Dataset C:\arcgisserver\python\FindFeatures2\Features.gdb\KCC_InputFeature_GenerateNea8 already exists. esriJobMessageTypeError: The value does not exist. The value does not exist. The value does not exist. ERROR 000732: Near Features: Dataset GuidedWalks;KCC_PROMOTED_ROUTEZ_2;KCC_COUNTRYPARKZ does not exist or is not supported ERROR 000732: Join Features: Dataset KCC_COUNTRYPARKZ does not exist or is not supported ERROR 000732: Join Features: Dataset KCC_PROMOTED_ROUTEZ_2 does not exist or is not supported ERROR 000732: Join Features: Dataset GuidedWalks does not exist or is not supported WARNING 000725: Output Dataset: Dataset C:\arcgisserver\python\FindFeatures2\Features.gdb\KCC_InputFeature_GenerateNea8 already exists. esriJobMessageTypeError: Failed. [/HTML] Regards Ganesh
... View more
03-19-2014
12:55 PM
|
0
|
0
|
204
|
POST
|
HI James Once agian, thank you very much for the code and working sample. Unfortunately, when I tried to play with your application, it didn't allow me, as it require AGOL account to log on to view the result. Other, than the application seems stunning and i could lot of points data near the gulf mexico and one tower image as well. anyway thank you for your help. To let you know, I have solved geoprocessing problem i have with my model. Actually, When I publish the model alone as a geprocessing service, it reports that the near layer data are not found. When I include the model in the Arcmap mxd document and published them as a geoprocessing service with result map service, the model tries to work and it could get the results for my near features in the rest end point. To be honest, I really don't know why the model works when it is published as a geoprocessing with result map service and why it doesn't work when it is published just a model and basically, it is mystery. Now, my next step is to integrate my geoprocessing result map service into web application to see how it works. I have to write my javascript code and it is a real challenge here to see how it works. Regards Ganesh You can see my app for a limited period here: http://deloittegeospatial.github.io/ Code here: https://github.com/DeloitteGeospatial/deloittegeospatial.github.io/blob/master/js/arcgis.js Getting published GP services to work is a whole different problem set. I'm sure you've seen these documents but I would start here: http://resources.arcgis.com/en/help/main/10.2/index.html#/Analyzing_a_geoprocessing_service/00570000006v000000/
... View more
03-19-2014
12:51 PM
|
0
|
0
|
379
|
POST
|
Hi Guys, I have built my Geoprocessing model to find nearest feature from the input location in model builder and published them as a geoprocessing service. The model works perfectly well in ARCGIS desktop. when I published them as a geoprocessing service, and tested the service with REST end points in arcgis server using submit Job Operation, I got the following error. Basically, the error reports that NearFeature layers doesn't exist, but in reality it does exist in the map and it has hard coded and the second issue is the output datasets -from the geoprocessing service reports that the data already exist. Actually, I have checked the Overwrite Outputs of geoprocessing operations in Arccatalog and ArcMap before building the model. The model overwrites output datasets and finds all near feature layers when it is run from Arcmap. However, when it is run from REST end points, it causes errors saying data already exist or not found. Have anyone come across this issue when publishing them as a geoprocessing service. Anyhelp would be much appreciated. [HTML]Job Details: Model Check Job Details: Return Messages: True False View In: Google Earth Job ID: j4b4f0182872145a093f614736caf1486 Job Status: esriJobFailed Job Messages: esriJobMessageTypeInformative: Submitted. esriJobMessageTypeInformative: Executing... esriJobMessageTypeInformative: esriJobMessageTypeWarning: WARNING 000725: KCC_InputFeature_GenerateNea8: Dataset C:\arcgisserver\python\FindFeatures2\Features.gdb\KCC_InputFeature_GenerateNea8 already exists. esriJobMessageTypeError: The value does not exist. The value does not exist. The value does not exist. ERROR 000732: Near Features: Dataset GuidedWalks;KCC_PROMOTED_ROUTEZ_2;KCC_COUNTRYPARKZ does not exist or is not supported ERROR 000732: Join Features: Dataset KCC_COUNTRYPARKZ does not exist or is not supported ERROR 000732: Join Features: Dataset KCC_PROMOTED_ROUTEZ_2 does not exist or is not supported ERROR 000732: Join Features: Dataset GuidedWalks does not exist or is not supported WARNING 000725: Output Dataset: Dataset C:\arcgisserver\python\FindFeatures2\Features.gdb\KCC_InputFeature_GenerateNea8 already exists. esriJobMessageTypeError: Failed. [/HTML] Regards Ganesh
... View more
03-19-2014
01:45 AM
|
0
|
1
|
1014
|
POST
|
Hi James Thank you very much for your code. Can you provide some working sample code, at the moment, I can't see how it works. If you can provide this, that would be really good. One more thing, I have built my Geoprocessing model to find nearest feature from the input location in model builder and published them as a geoprocessing service. The model works perfectly well in ARCGIS desktop. when I published them as a geoprocessing service, and tested the service with REST end points in arcgis server using submit Job Operation, I got the following error. Basically, the error reports that NearFeature layers doesn't exist, but in reality it does exist in the map and it has hard coded and the second issue is the output datasets -from the geoprocessing service reports that the data already exist. Actually, I have checked the Overwrite Outputs of geoprocessing operations in Arccatalog and ArcMap before building the model. The model overwrites output datasets and finds all near feature layers when it is run from Arcmap. However, when it is run from REST end points, it causes errors saying data already exist or not found. Have anyone come across this issue when publishing them as a geoprocessing service. Anyhelp would be much appreciated. Job Details: Model Check Job Details: Return Messages: True False View In: Google Earth Job ID: j4b4f0182872145a093f614736caf1486 Job Status: esriJobFailed Job Messages: esriJobMessageTypeInformative: Submitted. esriJobMessageTypeInformative: Executing... esriJobMessageTypeInformative: esriJobMessageTypeWarning: WARNING 000725: KCC_InputFeature_GenerateNea8: Dataset C:\arcgisserver\python\FindFeatures2\Features.gdb\KCC_InputFeature_GenerateNea8 already exists. esriJobMessageTypeError: The value does not exist. The value does not exist. The value does not exist. ERROR 000732: Near Features: Dataset GuidedWalks;KCC_PROMOTED_ROUTEZ_2;KCC_COUNTRYPARKZ does not exist or is not supported ERROR 000732: Join Features: Dataset KCC_COUNTRYPARKZ does not exist or is not supported ERROR 000732: Join Features: Dataset KCC_PROMOTED_ROUTEZ_2 does not exist or is not supported ERROR 000732: Join Features: Dataset GuidedWalks does not exist or is not supported WARNING 000725: Output Dataset: Dataset C:\arcgisserver\python\FindFeatures2\Features.gdb\KCC_InputFeature_GenerateNea8 already exists. esriJobMessageTypeError: Failed. Regards Ganesh Ganesh, Sure: http://jsfiddle.net/geo_james/uDX9a/1/ A free developer AGOL account works fine. I was considering my own GP model if I couldn't get this to work but we eventually cracked it. Thanks to Derek. Cheers, James
... View more
03-19-2014
01:38 AM
|
0
|
0
|
1044
|
POST
|
Hi James Could please post your sample codes in JS fiddle for the find nearest functionality? At the moment, I can't find any sample codes in the ESRI javascript api for find nearest features. https://developers.arcgis.com/rest/a...nd-nearest.htm Do we need to have an AGOL account to use this service? or is this any free developer account to this service. At the moment, I am developing my own geoprocessing service using model builder to create my own custom service to integrate into my application. http://forums.arcgis.com/threads/103522-NearAnalysis-Geoprocessing-Service-arcgis-javascript-api Please read above thread, I will post some model builder sample later this week. thanks ganesh
... View more
03-17-2014
11:27 AM
|
0
|
0
|
1044
|
POST
|
Ganesh, Thanks for letting us know. I was able to reproduce the fact that the delete button and delete listener aren't working on Chrome in the Attribute Inspector sample. I can see that saves are working by using the browser console. Are you able to see the saves occurring in the background? Have you opened a support ticket yet? That way we can get this tracked and in the queue. If you need a quick fix you can always manually build your own custom delete button and set the default delete button to false. Here is a psuedo-code example to get you pointed in the right direction:
var layerInfos = [{
'featureLayer': petroFieldsFL,
'showAttachments': false,
'showDeleteButton': false, /* set this to false */
....
var dButton = new Button({ label: "Delete", "class": "dButton"});
domConstruct.place(dButton.domNode, attInspector.deleteBtn.domNode, "after");
dButton.on("click",function(evt){
updateFeature.getLayer().applyEdits(null,null,[updateFeature]);
map.infoWindow.hide();
})
https://developers.arcgis.com/javascript/jsapi/attributeinspector.html#event-delete -Andy Hi Andy thank you very much for your quick turnaround. I am really amazed to see that you have responded to my query. The only problem is with the delete button and the save button works perfectly alright. I haven't logged a ticket with ESRI and to be honest, I don't how to log a support ticket with ESRI. Please guide on this. Finally, I will try to create a custom delete button as per your advice and see whether that one works and finally, a big thank you for the custom code as well. Regards Ganesh
... View more
02-28-2014
04:30 AM
|
0
|
0
|
353
|
POST
|
HI Guys, I have created a model in model builder and published a Geoprocessing service to call that service within my arcgis javascript application. The reason for creating this Geoprocessing tool is to identify the list of 5 near features along with their distances from the input location. The input location is a point where as near features can be point, line and polygons. when the Near feature is a line or polygon, it should query against the nearest vertex of the line or polygon rather than using the centroid of the polygon. So I have used "Generate NearTable" geoprocessing tool and published them as a service (Please see attached png file). The geoprocessing tool is working perfectly within ARCMap environment, not sure within arcgis javascript environment. My only concern is the input and output datatype parameters for the geoprocessing service, I published to the server. If you look at the Metadata for this services below, you could understand the input and output parameters required. InputLocation: datatype is ok, as it can accept any feature set -so there is no problem with this. NearFeatures: the problem is with the near features datatype (GPMultiValue:gpstring). I am not sure whether arcgis javascript api, will accept this datatype as an input to our feature layer within our application. Basically, feature layer can be point, line and polygon. I am planning input the near feature as featureset to the GPMultivalue datatype and I am not sure whether javascript api will accept this parameter. any help on this would be much appreciated. Task: NearAnalysis
Display Name: NearAnalysis
Category:
Execution Type: esriExecutionTypeAsynchronous
Parameters:
Parameter: InputLocation
Data Type: GPFeatureRecordSetLayer
Display Name: InputLocation
Direction: esriGPParameterDirectionInput
Default Value:
Parameter Type: esriGPParameterTypeRequired
Category:
Parameter: NearFeatures
Data Type: GPMultiValue:GPString
Display Name: NearFeatures
Direction: esriGPParameterDirectionInput
Default Value: null
Parameter Type: esriGPParameterTypeRequired
Category:
Parameter: FoundNear5Features_shp
Data Type: GPFeatureRecordSetLayer
Display Name: FoundNear5Features.shp
Direction: esriGPParameterDirectionOutput
Default Value:
Geometry Type: esriGeometryPoint
Spatial Reference: 27700
Fields:
FID (Type: esriFieldTypeOID, Alias: FID)
Shape (Type: esriFieldTypeGeometry, Alias: Shape)
IN_FID (Type: esriFieldTypeInteger, Alias: IN_FID)
NEAR_FID (Type: esriFieldTypeInteger, Alias: NEAR_FID)
NEAR_DIST (Type: esriFieldTypeDouble, Alias: NEAR_DIST)
NEAR_X (Type: esriFieldTypeDouble, Alias: NEAR_X)
NEAR_Y (Type: esriFieldTypeDouble, Alias: NEAR_Y)
Parameter Type: esriGPParameterTypeRequired
Category:
Supported Operations: Submit Job
Supported Interfaces: REST
... View more
02-26-2014
04:31 AM
|
0
|
0
|
801
|
POST
|
Ganesh, you're right. I misunderstood your requirements. When you said that you want to use any kind of feature, I've thought about using the polygon centroids (in case of polygons) and the line middle points. If you need the closest vertices, this solution won't work. I don't know the how the arctoolbox tool that you talk works, so I think that I can't help here. HI GIS folks, Can you anyone give me a clue on this or point me the right sample application to work on. Regards Ganesh
... View more
02-25-2014
09:21 AM
|
0
|
0
|
1415
|
POST
|
Hi Kevin, Attached is an example on how to do this. The application searches for a park by it's name. What I did was added the below code to a new JavaScript file called 'find.js': require([
"esri/map",
"esri/tasks/QueryTask",
"esri/tasks/query",
"esri/geometry/Extent",
"esri/SpatialReference",
"esri/InfoTemplate",
"esri/graphic",
"esri/symbols/SimpleFillSymbol",
"esri/symbols/SimpleLineSymbol",
"dojo/parser",
"dojo/dom",
"dojo/on",
"dojo/ready"],
function(
Map, QueryTask, Query, Extent, SpatialReference, InfoTemplate,
Graphic, SimpleFillSymbol, SimpleLineSymbol,
parser, dom, on, ready
){
ready(function() {
var button = dojo.byId("typeButton")
on(button, "click", findPark)
function findPark(){
map.graphics.clear();
var queryTask = new QueryTask("http://services.arcgis.com/Fz6BBJUji5ArUSDM/arcgis/rest/services/Parks/FeatureServer/0");
var query = new Query();
query.returnGeometry = true;
query.outFields = ["*"];
query.outSpatialReference = {"wkid":102100};
query.where = "NAME = '" + dojo.byId("txtBox").value + "'";
queryTask.execute(query);
queryTask.on("complete", selectResults)
}
function selectResults(graphics){
var parkName = graphics.featureSet.features[0].attributes["NAME"];
var park = new Graphic(graphics.featureSet.features[0].geometry);
var infoTemplate = new InfoTemplate("PARK:", parkName);
park.setInfoTemplate(infoTemplate);
map.graphics.add(park);
var extent = new Extent(map.graphics.graphics[0].geometry._extent.xmin, map.graphics.graphics[0].geometry._extent.ymin, map.graphics.graphics[0].geometry._extent.xmax, map.graphics.graphics[0].geometry._extent.ymax, new SpatialReference({ wkid:102100 }));
map.setExtent(extent, true);
featureArray = [];
featureArray.push(park);
var templatePt = park.geometry.getCentroid();
map.infoWindow.setFeatures(featureArray);
map.infoWindow.show(templatePt);
}
})
}); Next, I updated the index.html to call the new javascript file: <script type="text/javascript" src="javascript/find.js"> And to create the text box and button: <div id="webmap-toolbar-left">
<input type="text" id="txtBox">
<input type="button" id="typeButton" value="Find Park">
</div> You can search for park, i.e. 'Fairmount Park', and the app will select, zoom to the park, and display a pop-up. Hi jskinner Really nice functionality. Thank you for this. Actually, I need some help from you. Basically I am trying to find nearest features from an input location. The near feature location would be point, line and polygon and I need to query 5 nearest features and if the nearest feature is a line or polygon then it should find the nearest vertices from the line or polygon rather than using the centroid to calculate their distance. Can you point me to the sample code please. Regards Ganesh
... View more
02-21-2014
10:59 PM
|
0
|
0
|
672
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|