<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Remove a map layer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26834#M2310</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Here is the relevant code changes to what Tim and you worked on.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // On Job Complete Callback add a dynamic map service using ResultMapService
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function onTaskComplete(jobInfo) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(app.gpResultLayer){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.removeLayer(app.gpResultLayer);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //replace mapservice url with your url and append jobid
&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var mapurl = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://bhc.coas.oregonstate.edu:6080/arcgis/rest/services/geoprocessing/RasterPlusModel/MapServer/jobs/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://bhc.coas.oregonstate.edu:6080/arcgis/rest/services/geoprocessing/RasterPlusModel/MapServer/jobs/&lt;/A&gt;&lt;SPAN&gt;" + jobInfo.jobId;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //create a dynamic map service
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app.gpResultLayer = new esri.layers.ArcGISDynamicMapServiceLayer(mapurl, {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id: "WeightedSum",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; opacity: 0.5
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //add to web application.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayer(app.gpResultLayer);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app = {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myGPSubmitJob: myGPSubmitJob,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gpResultLayer: null
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Dec 2021 21:05:54 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2021-12-10T21:05:54Z</dc:date>
    <item>
      <title>Remove a map layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26833#M2309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Last week the GeoNet community helped me get my fist web map application functioning!&amp;nbsp; Ive made a bit of progress since and find myself up against the limits of my javascript skill again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've got an app that calls a geoprocessing service and returns a map result.&amp;nbsp; It works as intended, once.&amp;nbsp; When I fire off a subsequent SubmitJob the new map layer is drawn underneath the existing layer (I presume it's drawn underneath because I don't see it).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, seems that I could have the new layer draw on top using an index value but I'd rather just remove the layer and replace it with the new layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The function to add the layer looks like this:&lt;/P&gt;&lt;P&gt;// On Job Complete Callback add a dynamic map service using ResultMapService&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; function onTaskComplete(jobInfo, n){&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //replace mapservice url with your url and append jobid&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var mapurl = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://bhc.coas.oregonstate.edu:6080/arcgis/rest/services/geoprocessing/WeightedSum/MapServer/jobs/" rel="nofollow" target="_blank"&gt;http://bhc.coas.oregonstate.edu:6080/arcgis/rest/services/geoprocessing/WeightedSum/MapServer/jobs/&lt;/A&gt;&lt;SPAN&gt;" + jobInfo.jobId;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //create a dynamic map service&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var gpResultLayer = new esri.layers.ArcGISDynamicMapServiceLayer(mapurl, {&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id: "WeightedSum",&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; opacity: 0.5&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //remove any existing model results and add new model result to the web application.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayer(gpResultLayer, n);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;TABLE height="29" style="width: 19px; height: 30px;" width="18"&gt;&lt;TBODY&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;I think I'd like to "remember" or return the gpResultLayer from this function such that the next time it executes I can add a map.removeLayer(gpResultLayerPrevious) before adding the new layer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried adding:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var gpResultLayerPrevious = gpResultLayer&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;map.removeLayer(gpResultLayerPrevious)&lt;/P&gt;&lt;P&gt;to the above function but I think I need to make sure it gets returned from the function then passed in each time.&amp;nbsp; Any suggestions to how this might work?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks, Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Mar 2015 21:30:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26833#M2309</guid>
      <dc:creator>ChrisRomsos</dc:creator>
      <dc:date>2015-03-05T21:30:45Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a map layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26834#M2310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Here is the relevant code changes to what Tim and you worked on.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // On Job Complete Callback add a dynamic map service using ResultMapService
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; function onTaskComplete(jobInfo) {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(app.gpResultLayer){
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.removeLayer(app.gpResultLayer);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //replace mapservice url with your url and append jobid
&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var mapurl = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://bhc.coas.oregonstate.edu:6080/arcgis/rest/services/geoprocessing/RasterPlusModel/MapServer/jobs/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://bhc.coas.oregonstate.edu:6080/arcgis/rest/services/geoprocessing/RasterPlusModel/MapServer/jobs/&lt;/A&gt;&lt;SPAN&gt;" + jobInfo.jobId;&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //create a dynamic map service
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app.gpResultLayer = new esri.layers.ArcGISDynamicMapServiceLayer(mapurl, {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; id: "WeightedSum",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; opacity: 0.5
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //add to web application.
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map.addLayer(app.gpResultLayer);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; app = {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myGPSubmitJob: myGPSubmitJob,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gpResultLayer: null
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:05:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26834#M2310</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-10T21:05:54Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a map layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26835#M2311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Robert,&lt;/P&gt;&lt;P&gt;I tried to implement your suggestion above here: &lt;A href="http://bhc.coas.oregonstate.edu/GeoProcess/pasta.html" title="http://bhc.coas.oregonstate.edu/GeoProcess/pasta.html" rel="nofollow noopener noreferrer" target="_blank"&gt;PASTA&lt;/A&gt;&lt;/P&gt;&lt;P&gt;However the previous map layer remains.&amp;nbsp; I'll post my javascript below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var app;

&amp;nbsp; require([
&amp;nbsp; "esri/map",
&amp;nbsp; "esri/layers/ArcGISDynamicMapServiceLayer",
&amp;nbsp; "esri/dijit/BasemapToggle",
&amp;nbsp; "dojo/on",
&amp;nbsp; "dojo/parser",
&amp;nbsp; "esri/tasks/Geoprocessor",
&amp;nbsp; "dojo/dom",
&amp;nbsp; "dijit/layout/BorderContainer",
&amp;nbsp; "dijit/form/Button",
&amp;nbsp; "dojo/domReady!",
&amp;nbsp; "dijit/form/HorizontalSlider",
&amp;nbsp; "dijit/form/HorizontalRuleLabels",
&amp;nbsp; "dijit/form/HorizontalRule"


&amp;nbsp; ], function (Map,ArcGISDynamicMapServiceLayer,BasemapToggle,on,parser,Geoprocessor,dom,HorizontalSlider,HorizontalRuleLabels,HorizontalRule)
&amp;nbsp; {


&amp;nbsp; parser.parse();


&amp;nbsp; map = new Map("map", {
&amp;nbsp;&amp;nbsp; basemap: "topo",
&amp;nbsp;&amp;nbsp; center: [-124.5, 44.15],
&amp;nbsp;&amp;nbsp; zoom: 8
&amp;nbsp; });


&amp;nbsp; var toggle = new BasemapToggle({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; map: map,
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; basemap: "satellite"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, "BasemapToggle");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; toggle.startup();

&amp;nbsp; // Make 2 Horizontal Sliders Programatically
&amp;nbsp; // Create the rules
&amp;nbsp; var rulesNode = dojo.create(
&amp;nbsp; "div", {}, dojo.byId("horizSlider"), "first");
&amp;nbsp; var sliderRules = new dijit.form.HorizontalRule({
&amp;nbsp; container: "bottomDecoration",
&amp;nbsp; count: 11,
&amp;nbsp; style: "width: 5px;"
&amp;nbsp; }, rulesNode);
&amp;nbsp; var rulesNode2 = dojo.create(
&amp;nbsp; "div", {}, dojo.byId("horizSlider2"), "first");
&amp;nbsp; var sliderRules2 = new dijit.form.HorizontalRule({
&amp;nbsp; container: "bottomDecoration",
&amp;nbsp; count: 11,
&amp;nbsp; style: "width: 5px;"
&amp;nbsp; }, rulesNode);

&amp;nbsp; // Create the labels
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var labelsNode = dojo.create(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "div", {}, dojo.byId("horizSlider"), "first");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var sliderLabels = new dijit.form.HorizontalRuleLabels({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; container: "topDecoration",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; labelStyle: "font-style: italic; font-size: 0.75em"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, labelsNode);
&amp;nbsp; var labelsNode2 = dojo.create(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; "div", {}, dojo.byId("horizSlider2"), "first");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var sliderLabels2 = new dijit.form.HorizontalRuleLabels({
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; container: "topDecoration",
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; labelStyle: "font-style: italic; font-size: 0.75em"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }, labelsNode);

&amp;nbsp; // Create the sliders
&amp;nbsp;&amp;nbsp;&amp;nbsp; var horizSlider = new dijit.form.HorizontalSlider({
&amp;nbsp; minimum: 0,
&amp;nbsp; maximum: 1,
&amp;nbsp; pageIncrement: .20,
&amp;nbsp; value: .20,
&amp;nbsp; intermediateChanges: true,
&amp;nbsp; style: "height: 200px;"
&amp;nbsp; }, "horizSlider");

&amp;nbsp; var horizSlider2 = new dijit.form.HorizontalSlider({
&amp;nbsp; minimum: 0,
&amp;nbsp; maximum: 1,
&amp;nbsp; pageIncrement: .20,
&amp;nbsp; value: .20,
&amp;nbsp; intermediateChanges: true,
&amp;nbsp; style: "height: 200px;"
&amp;nbsp; }, "horizSlider2");

&amp;nbsp; // Start up the widgets
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; horizSlider.startup();
&amp;nbsp; //horizSlider2.startup();
&amp;nbsp; sliderRules.startup();
&amp;nbsp; //sliderRules2.startup();
&amp;nbsp; sliderLabels.startup();
&amp;nbsp; //sliderLabels2.startup();

&amp;nbsp; var horizLabel = dojo.byId("horizValue");
&amp;nbsp; var horizLabel2 = dojo.byId("horizValue2");

&amp;nbsp; function updateHorizontalLabel() {
&amp;nbsp; // Update label
&amp;nbsp; horizLabel.innerHTML = horizSlider.get("value");
&amp;nbsp; }
&amp;nbsp; function updateHorizontalLabel2() {
&amp;nbsp; // Update label
&amp;nbsp; horizLabel2.innerHTML = horizSlider2.get("value");
&amp;nbsp; }

&amp;nbsp; dojo.connect(horizSlider,"onChange",updateHorizontalLabel);
&amp;nbsp; // Update label right away
&amp;nbsp; updateHorizontalLabel();

&amp;nbsp; dojo.connect(horizSlider2,"onChange",updateHorizontalLabel2);
&amp;nbsp; // Update label right away
&amp;nbsp; updateHorizontalLabel2();

&amp;nbsp; var weightedValue1 = dojo.byId("WeightedValueValue1");
&amp;nbsp; var weightedValue2 = dojo.byId("WeightedValueValue2");
&amp;nbsp; var Weight1;
&amp;nbsp; var Weight2;

&amp;nbsp; function updateWeighting() {
&amp;nbsp; // Update weighting calculations

&amp;nbsp; var weightSum = horizSlider.get("value")+horizSlider2.get("value");
&amp;nbsp; var weightFactor = 1/weightSum;

&amp;nbsp; weightedValue1.innerHTML = horizSlider.get("value")*weightFactor;
&amp;nbsp; weightedValue2.innerHTML = horizSlider2.get("value")*weightFactor;

&amp;nbsp; Weight1 = horizSlider.get("value")*weightFactor;
&amp;nbsp; Weight2 = horizSlider2.get("value")*weightFactor;

&amp;nbsp; }

&amp;nbsp; dojo.connect(horizSlider,"onChange",updateWeighting);
&amp;nbsp; // Update the weighting right away
&amp;nbsp; updateWeighting();

&amp;nbsp; dojo.connect(horizSlider2,"onChange",updateWeighting);
&amp;nbsp; // Update the weighting right away
&amp;nbsp; updateWeighting();

&amp;nbsp; //&amp;nbsp; Geoprocessing

&amp;nbsp; /* Step 1: Initialize Geoprocessing Task as a global variable.
&amp;nbsp; That is, declare the variable outside a function definition
&amp;nbsp; since we will be using gpTask variable in other methods */
&lt;SPAN&gt;&amp;nbsp; var gpTaskUrl="&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://bhc.coas.oregonstate.edu:6080/arcgis/rest/services/geoprocessing/WeightedSum/GPServer/WeightedSum" rel="nofollow noopener noreferrer" target="_blank"&gt;http://bhc.coas.oregonstate.edu:6080/arcgis/rest/services/geoprocessing/WeightedSum/GPServer/WeightedSum&lt;/A&gt;&lt;SPAN&gt;";&lt;/SPAN&gt;
&amp;nbsp; var gpTask = new Geoprocessor(gpTaskUrl);

&amp;nbsp; // Set output spatial reference property to map's spatial reference.
&amp;nbsp; // myMap is assumed to be an instance of map container esri.map.
&amp;nbsp; gpTask.outSpatialReference=map.spatialReference; 

&amp;nbsp; on(dom.byId("hotspotButton"), "click", myGPSubmitJob);
&amp;nbsp; //Step 3: Run the task
&amp;nbsp; function myGPSubmitJob(n){
&amp;nbsp; // Get the input rasters
&amp;nbsp; var Raster1 = "Midwater Device\\Initial\\suitability";
&amp;nbsp; var Raster2 = "Cetaceans\\Initial\\suitability";
&amp;nbsp; var params= {"Raster1":Raster1, "Weight1":Weight1, "Raster2":Raster2, "Weight2":Weight2};


&amp;nbsp; // Setup event handlers.
&amp;nbsp; dojo.connect(gpTask, "onJobComplete",onTaskComplete);
&amp;nbsp; dojo.connect(gpTask, "onError",onTaskFailure);
&amp;nbsp; dojo.connect(gpTask, "onStatusUpdate",onTaskStatus);
&amp;nbsp; gpTask.submitJob(params);
&amp;nbsp; }

&amp;nbsp; // On Job Complete Callback add a dynamic map service using ResultMapService
&amp;nbsp; function onTaskComplete(jobInfo, gpResultLayerPrevious){


&amp;nbsp; if(gpResultLayer){
&amp;nbsp; map.removeLayer(gpResultLayer);
&amp;nbsp; }

&amp;nbsp; //replace mapservice url with your url and append jobid
&lt;SPAN&gt;&amp;nbsp; var mapurl = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://bhc.coas.oregonstate.edu:6080/arcgis/rest/services/geoprocessing/WeightedSum/MapServer/jobs/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://bhc.coas.oregonstate.edu:6080/arcgis/rest/services/geoprocessing/WeightedSum/MapServer/jobs/&lt;/A&gt;&lt;SPAN&gt;" + jobInfo.jobId;&lt;/SPAN&gt;

&amp;nbsp; //create a dynamic map service
&amp;nbsp; var gpResultLayer = new esri.layers.ArcGISDynamicMapServiceLayer(mapurl, {
&amp;nbsp; id: "WeightedSum",
&amp;nbsp; opacity: 0.5
&amp;nbsp; });

&amp;nbsp; //remove any existing model results and add new model result to the web application.
&amp;nbsp; map.addLayer(gpResultLayer);

&amp;nbsp; // reset the gpResultlayerPrevious
&amp;nbsp; gpResultLayerPrevious = gpResultLayer;

&amp;nbsp; }


&amp;nbsp; // Event handler for onStatusUpdate event
&amp;nbsp; function onTaskStatus(jobInfo) {
&amp;nbsp; //write status to console to help debugging
&amp;nbsp; console.log(jobInfo.jobStatus);
&amp;nbsp; }

&amp;nbsp; // Event handler for onError event
&amp;nbsp; function onTaskFailure(error) {
&amp;nbsp; // Report error
&amp;nbsp; alert("Error:"+ error);
&amp;nbsp; }

&amp;nbsp;&amp;nbsp; app = {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; myGPSubmitJob: myGPSubmitJob,
&amp;nbsp; gpResultLayer: null
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; };
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:05:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26835#M2311</guid>
      <dc:creator>ChrisRomsos</dc:creator>
      <dc:date>2021-12-10T21:05:57Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a map layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26836#M2312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Your issue is that you are creating a local var :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var gpResultLayer = new esri.layers.ArcGISDynamicMapServiceLayer(mapurl, { 
&amp;nbsp; id: "WeightedSum", 
&amp;nbsp; opacity: 0.5 
&amp;nbsp; });&lt;/PRE&gt;&lt;P&gt;In my code I am using the app.gpResultLayer object which is global.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:05:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26836#M2312</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-10T21:05:59Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a map layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26837#M2313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks. - Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 22:07:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26837#M2313</guid>
      <dc:creator>ChrisRomsos</dc:creator>
      <dc:date>2015-03-06T22:07:41Z</dc:date>
    </item>
    <item>
      <title>Re: Remove a map layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26838#M2314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Chris,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Glad to help. Now it is your turn to help the community by marking this question as answered.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;All you have to do is click the "Correct Answer" link (the one with the little green star) on the post that provided the answer for you.&lt;/LI&gt;&lt;LI&gt;If the answer was not provided by one of the responders then you can mark any of the replies that you received as helpful by clicking on the "Actions" menu and choosing "Mark as Helpful"&lt;/LI&gt;&lt;/OL&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 06 Mar 2015 22:17:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/remove-a-map-layer/m-p/26838#M2314</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2015-03-06T22:17:11Z</dc:date>
    </item>
  </channel>
</rss>

