I am trying to set a Scale Range for a graphic layer using ArcGIS API in HTML5, so that the graphic layer is not visible on zooming beyond that particular ScaleRange.

For the same I have googled and looked into the ArcGIS API Documentation and examples but I am not able to find the correct syntax to do it.

Can anyone please throw in some suggestions for the syntax that I can try? Currently I have used syntax like:

  • graphics.setMinScale=20000000
  • graphics.minScale=20000000
  • esri.graphics.minScale=20000000
  • esri.graphics.setMinScale=20000000
  • graphics.setScaleRange=20000000, 40000000
  • esri.graphics.setScaleRange=20000000, 40000000

I don't know none of the above syntax seems to be working out.


1 Answer 1


All layers in Esri's JS API have minScale and maxScale properties. This includes graphics layers. Once you've created a layer, you can you set minScale and maxScale directly (probably not recommended) or use one of the methods like setMinScale, setMaxScale or setScaleRange.

It looks like you were getting close to this with the stuff in your bulleted list but you're confusing properties and methods. Properties can be assigned a value with the syntax object.something = value but you have have to call methods. For example, calling a method: object.setScaleRange(min, max). You could also use zoom levels if your basemap is cached.

Modified version of a sample that shows this (zoom in or out to get outside the visible scale range for the graphics layer): http://jsbin.com/cihuvi/1/

  • you are right in that all along i was close to it but mixed up properties and functions. So now i have used map.graphics.setScaleRange(20000000, 2500000); and it works. Still what bothers me is that I cannot set the Scale Range for individual graphic layers. Right now for all graphic layers the visibilty Range is same. I really appreciate your answer and the example link you have put up to showcase the same. Thanks for all the effort Nov 13, 2014 at 5:28
  • 2
    @abhinavgoyal02 you can control varying scale ranges for different graphics by passing them to different named GraphicsLayers instead of adding them all to the anonymous graphics layer (map.graphics) that is set up 'out of the box'. Nov 13, 2014 at 16:39
  • 1
    @JohnGravois like my agenda is to make the graphic smaller on zoom-out and bigger when zooming-in. So right now i am just making multiple copies of the same graphic layer and changing the size of the symbols used for them. Each copy of graphic is used at different scale ranges like smaller one at zoom-out and bigger one at zoom-in. Is there a better way of doing the same? Nov 14, 2014 at 10:43
  • can we dynamically change the size of the graphic in a graphic Layer on zoom event of the map object, such that the graphic resizes as we zoom-in or zoom-out of the map? Nov 17, 2014 at 5:33
  • 1
    @abhinavgoyal02 it's possible, but that's not something you should need to do. If you really need to do that, you should write up a new question with a detailed use case and explanation of why you need to change graphics sizes on the fly and post it. Nov 17, 2014 at 20:32

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.