2

I have a JS code like this which I have assigned an anonymous function to photos variable in map.on("load", function() {} now it seems the photos is never invoking! as even I tried to do a simple console.log("Is This working") it is not loading the log!

I am using the second function instead of ESRI's builtin esriRequest(); since the native function is already taking URL to read JSON file from server but I am making points dynamically on fly. so I tough I must use mu own function here.

 var photos;
 map.on("load", function() {
          domStyle.set(query("a.action.zoomTo")[0], "display", "none");
          photos = function(){
            for (var i = 0; i < projects.length; i++) {
            var point = new Point(projects[i].Longitude, projects[i].Latitude);
            var pointSymbol = new SimpleMarkerSymbol(); 
            pointSymbol.setStyle(SimpleMarkerSymbol.STYLE_CIRCLE);
            pointSymbol.setSize(9);
            var pointInfoTemplate = new InfoTemplate(); 
            pointInfoTemplate.setTitle("Project Details");
            pointInfoTemplate.setContent('   ');
            var pointGraphic = new Graphic(point, pointSymbol).setInfoTemplate(pointInfoTemplate);
            points.push(pointGraphic);
        }
        for (i = 0; i < points.length; ++i) {
            map.graphics.add(points[i]);
        }
        console.log(points);
        };
            photos.then(addClusters, error);
        });

Can you please let me know why this is not working?

1
  • Which version of the JS API are you using?
    – GavinR
    Commented Aug 29, 2015 at 2:43

1 Answer 1

4

Your line:

photos.then(addClusters, error);

... is not calling the photos function. You would have to add parenthesis like this:

photos().then(addClusters, error);

Note that you can only call .then(...) on a function that returns a deferred, so you may have problems having this code call addClusters too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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