Problems with a function - query a JSON array to return fields in a map service url?

المشرف العام

Administrator
طاقم الإدارة
This is an extract of my JSON.

{"id": "1", "layer": "0", "min_scale": "0", "url": "http://example.service.url" "max_scale": "5000000", "field": [ "NAME", "PA_CODE", "TYPE", "STATUS" ] }, { "id": "2", "layer": "5", "url": "http://mapservice.examples", "max_scale": "250001", "field": [ "Category" ] },I've created a for loop that pulls the service url and shows a map layer depending on what the user clicks on:

var myID = $(this).attr('data-url'); for (index in jsonString.Land) { //alert('Index of for loop ' + index); if (jsonString.Land[index].id == myID) { var layerURL = jsonString.Land[index].url; var layerids = jsonString.Land[index].layer; var fields = jsonString.Land[index].field; //alert('LayerURL or record ' + layerURL + layerids); addLayertoMap(layerURL, layerids, fields) //debugger; } }I'd now like to show the field values related to the url and show the values for the fields in another div, depending on what map service the user clicks on. I'm just unsure about what the function should be. At the moment I'm just getting the "NAME", "PA_CODE", "TYPE", "STATUS" in a list rather than the values associated with them? This is the code I used to add the map layer to my map application:

function addLayertoMap(layerURL, layerID) { var dynamicLayer = map.getLayer("DynamicLayer"); if (dynamicLayer) { map.removeLayer(dynamicLayer); } var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer(layerURL, { "id": "DynamicLayer" }); //alert(layerID); dynamicMapServiceLayer.setVisibleLayers([layerID]); map.addLayer(dynamicMapServiceLayer); }Can anyone help? Much appreciated if you have any pointers?



أكثر...
 
أعلى