2

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.

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Nov 12, 2014 at 8:31
0

1 Answer 1

2

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/

answered Nov 12, 2014 at 17:59
6
  • 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 Commented 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'. Commented 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? Commented 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? Commented 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. Commented Nov 17, 2014 at 20:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.