0
            //Define the default inputs for the Hot Spot widget
        var hotSpotParams = {
            id: "analysisTool",
            analysisLayer: sex_offenders,
            portalUrl: "http://utdepps.maps.arcgis.com/home/organization.html",
            aggregationPolygonLayers: [sex_offenders],
            boundingPolygonLayers: [sex_offenders],
            showHelp: false,
            showSelectAnalysisLayer: false,
            showCredits: false,
            map: map,
            returnFeatureCollection: true
        };

        var hotSpots = new FindHotSpots(hotSpotParams, "hotSpotDiv");
        hotSpots.startup();

        //If any errors occur reset the widget (Not Working...troubleshoot)
        on(hotSpots, "job-fail", function(params){
            resetTool("error");
        });
        on(hotSpots, "job-status", function(status){
          if(status.jobStatus === 'esriJobFailed'){
          alert("Job Failed: " + status.messages[0].description);
            resetTool("error");
          }

        });
        on(hotSpots, "job-cancel", function(){
            resetTool("error");
        });
        on(hotSpots, "job-submit", function(result){
            //display the loading icon
            domUtils.show(dom.byId("loader"));
            resetTool("submit");

        });
        //The hot spots analysis has finished successfully - display the results
        on(hotSpots, "job-result", function(result){

            //hide the loading icon
            domUtils.hide(dom.byId("loader"));

            //add the results to the map and display the legend.
            if(result.value){
                var template = new InfoTemplate("Results", "${*}");
                var resultLayer = new FeatureLayer(result.value.url || result.value, {
                    infoTemplate: template,
                    outFields: ["*"],
                    opacity: 0.7, //default too transparent
                    id: "resultLayer"
                });

                map.addLayer(resultLayer);
                //refresh and display the legend
                domUtils.show(dom.byId("legendContainer"));
                legend.refresh([{layer: resultLayer}]);
            }
            if(result.analysisReport){
                //hide the hot spots panel and show the analysis info.
                domUtils.hide(dom.byId("toolPanel"));
                domUtils.show(dom.byId("infoPanel"));
                dom.byId("analysisInfo").innerHTML = result.analysisReport;
            }

            //re-enable the hot spots tool
            hotSpots.set("disableRunAnalysis", false);

        });
    }

    function resetTool(status){
        if(status === "error"){
            var tool = registry.byId("analysisTool");
            tool.set("disableRunAnalysis", false);
        }
        //Analysis started lets clean up any old results
        //Hide the legend, remove the results layer
        var layer = map.getLayer("resultLayer");
        if(layer){
            map.removeLayer(layer);
        }
        domUtils.hide(dom.byId("legendContainer"));
    }
    function showToolPanel(){
      //expand the right panel to display the content
        var cp = registry.byId("rightPanel");
        domStyle.set(cp.domNode, {width: "20%"});
        registry.byId("mainWin").resize();

        map.reposition();
        map.resize();
    }
  });
});

I'm trying to use JavaScript API to program a widget to give generate a hot spot analysis of sex offenders. My program seems to be having trouble connecting to arcgis.com (if I use https://www.arcgis.com, it prompts for a login screen. No credentials will work). I can load the feature classes, but I can't seem to get the analysis function to work.

  • I'm assuming that you are using Portal for ArcGIS so I've added a tag for that. – PolyGeo Dec 8 '18 at 21:09
0

In your hotSpotParams object, try setting portalUrl to https://utdepps.maps.arcgis.com.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.