Hi,
Below is the code which is for spatial query.
var map;
var resultFromquery = [];
require(["esri/map", "esri/layers/ArcGISDynamicMapServiceLayer",
"esri/layers/ImageParameters","esri/geometry/Extent","esri/InfoTemplate","esri/SpatialReference","esri/tasks/query","esri/tasks/QueryTask","esri/graphic","esri/tasks/FeatureSet","esri/symbols/Symbol", "dojo/domReady!"],
function(Map,ArcGISDynamicMapServiceLayer,ImageParameters,Extent,InfoTemplate,SpatialReference,query,QueryTask,graphic,FeatureSet,Symbol)
{
map = new Map("map", {
basemap: "topo",
center: [75.831,18.895], // longitude, latitude
zoom: 10,
//maxScale:8800
});
map.on("click", mapReady);
var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("Mapservice");
dynamicMapServiceLayer.setVisibleLayers([0]);
map.addLayer(dynamicMapServiceLayer);
infoTemplate = new esri.InfoTemplate("${BLDGNO}", "Locality: ${SUBLOCALITY}<br />StateName: ${STATENAME}<br />Pincode: ${PINCODE}");
symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_DASHDOT, new dojo.Color([255,0,0]), 2), new dojo.Color([255,255,0,0.5]));
});
function mapReady(evt)
{
queryTask = new esri.tasks.QueryTask("Mapservice");
query = new esri.tasks.Query();
query.returnGeometry = true;
query.outFields = ["BLDGNO", "SUBLOCALITY", "STATENAME","CITYNAME","PINCODE"];
query.geometry = evt.mapPoint;
queryTask.execute(query, showResults);
}
function showResults(featureSet)
{
dojo.forEach(featureSet.features,function(feature)
{
var graphic = feature;
resultFromquery.push(feature.attributes);
graphic.setSymbol(symbol);
graphic.setInfoTemplate(infoTemplate);
map.graphics.add(graphic);
});
}
document.getElementById('SubmitBtn').onclick = function myFunction()
{
try
{
var i;
var BLDGNO ="";
var PINCODE="";
for (i=0;i<resultFromquery.length;i++)
{
BLDGNO = resultFromquery[i].BLDGNO;
PINCODE = resultFromquery[i].PINCODE;
console.log(BLDGNO , PINCODE);
}
}
catch (err)
{
alert(err.message);
}
}
I wanted to know how to prevent (to show a alert or message) selecting the polygon which is already selected.
Thanks,
AS
Solved! Go to Solution.
AS,
You would have to get an array of ObjectIds that are already selected and
AS,
You would have to get an array of ObjectIds that are already selected and