I've developed an application on leaflet JS
, which loads the services from local ArcGIS server
through Arcgis REST API
.
The following code loads the service:
function addServiceToMap(service, layers = ""){
if(service){
let url = "http://domain/arcgis/rest/services/" + service + "/MapServer?layers=show:" + layers + "&token="+token;
let new_service = L.esri.dynamicMapLayer({
url: url,
opacity : 1,
useCors: false,
f: 'image'
});
new_service.addTo(map);
}
}
The problem is, to hide a layer, I have to call this function, showing the required layers in the URL. Therefore, I add the service repeatedly.
Is there a better way?