I need to query arcGIS map service and add this result to another feature service using ArcGIS JavaScript API. I should not use MAP object.
I did query data without map from ArcGIS sample: Now i need to post this data to feature service:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<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>Query State Info without Map</title>
<script src="http://js.arcgis.com/3.9/"></script>
<script>
require([
"esri/tasks/query", "esri/tasks/QueryTask",
"dojo/dom", "dojo/on", "dojo/domReady!"
], function (Query, QueryTask, dom, on) {
var queryTask = new QueryTask("http://xxxx/arcgis/rest/services/REGIS/xxx/MapServer/1");
var query = new Query();
query.returnGeometry = true;
query.outFields = [
"PIN", "PDAREA "
];
on(this, "load", execute);
function execute() {
//query.where = "PIN in (" + getParameterByName("PINS") + ")";
query.where = "PIN in (1010027)";
queryTask.execute(query, showResults);
}
function showResults(results) {
var resultItems = [];
var resultCount = results.features.length;
for (var i = 0; i < resultCount; i++) {
newfeatGeom = JSON.stringify(results.features[i].geometry);
newAtt = JSON.stringify(results.features[i].attributes);
finalObj = newfeatGeom.concat(newAtt);
var featureAttributes = results.features[i].attributes;
for (var attr in featureAttributes) {
resultItems.push("<b>" + attr + ":</b> " + featureAttributes[attr] + "<br>");
}
resultItems.push("<br>");
}
dom.byId("info").innerHTML = resultItems.join("");
}
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
});
</script>
</head>
<body>
US state name :
<br />
<div id="info" style="padding: 5px; margin: 5px; background-color: #eee;">
</div>
</body>
</html>
Any Idea?