I'm trying to add REST map services from a JSON file I have. The file includes the service url values and I'd like to add these to a map. Users click on a table of contents and the service name and owner are returned including the url text but not sure how to add the service to my basemap:
$(document).ready(function () {
for (index in jsonString.Land) {
$('#land ul').append('<li><a href="#" data-owner="' + jsonString.Land[index].owner + '">' + jsonString.Land[index].name + '</a></li>');
}
for (index in jsonString.Air) {
$('#air ul').append('<li><a href="#" data-url="' + jsonString.Air[index].url + '" data-owner="' + jsonString.Air[index].owner + '">' + jsonString.Air[index].name + '</a></li>');
}
for (index in jsonString.Water) {
$('#water ul').append('<li><a href="#" data-url="' + jsonString.Water[index].url + '" data-owner="' + jsonString.Water[index].owner + '">' + jsonString.Water[index].name + '</a></li>');
}
for (index in jsonString.Heritage) {
$('#heritage ul').append('<li><a href="#" data-url="' + jsonString.Heritage[index].url + '" data-owner="' + jsonString.Heritage[index].owner + '">' + jsonString.Heritage[index].name + '</a></li>');
}
for (index in jsonString.Waste) {
$('#waste ul').append('<li><a href="#" data-url="' + jsonString.Waste[index].url + '" data-owner="' + jsonString.Waste[index].owner + '">' + jsonString.Waste[index].name + '</a></li>');
}
$('a').on('click', function () {
$('#show').html($(this).attr('data-owner') + '<br>' + $(this).attr('data-url'));
});
});
I'd hope to add a variable featurelayer that indexes the JSON string?