Query AGS Service
Sample query AGS service returning distinct values only
by Bryan McIntosh
HTML
<script src="http://code.highcharts.com/stock/highstock.js"></script>
<SELECT id="list">
<OPTION VALUE="A">Service</OPTION>
<OPTION VALUE="C">Other</OPTION>
</SELECT>
<button id="btnQuery">Query</button>
<button id="btnClear">Clear</button>
<div id="container" style="height: 400px"></div>
JavaScript
function makeData(tsURL, tsName) {
var UniqueParams = [];
$.getJSON(tsURL, function (data) {
var resultList = data.features;
$.each(resultList, function( index, value ) {
alert( index + ": " + value.attributes.WS_TYPE);
UniqueParams[index] = value.attributes.WS_TYPE;
});
console.log(UniqueParams);
//$("#container").html(UniqueParams);
});
}
$("#btnQuery").click(function () {
makeData("http://maps.grandriver.ca/arcgis/rest/services/Public/GRCA_Watershed/MapServer/0/query?where=1=1&outFields=WS_TYPE&returnGeometry=false&returnDistinctValues=true&f=pjson", "yes");
});
$("#btnClear").click(function () {
$("#container").html("gg");
});