I would like to display the current map scale to the user in a web app builder application. Is this possible using a widget or does it require additional code?
If it requires additional code has anyone done this successfully and could share some resources/hints?
Update:
I should have been more specific in my question. I'm interested in knowing if the user is at 12,345 or 1,128 rather than giving them the ability to measure using a scalebar. My goal is to have some way to know when a user is asking why they can't see a layer to be able to tell them how far to go in. Or if they say that it needs to be visible at a certain scale I can quickly make the change rather than educated guessing. Is there another way to accomplish this goal?
Message was edited by: Brandon Keinath
Solved! Go to Solution.
This one shows the scale from the start.
My first code didn't show the scale because it only changed the innerhtml when the extend changed. Now it populates the innerhtml on startup.
Hey Brandon,
there is already a widget included that shows the scale. If you click on widgets when you create your map look for Scalebar.
Tim
Looking at it, it seems buggy to me.
Hi Tim,
Thanks for the quick reply. I see the scalebar widget now, but I guess I should have been more specific in my question. I'm interested in knowing if the user is at 12,345 or 1,128 rather than giving them the ability to measure using a scalebar. My goal is to have some way to know when a user is asking why they can't see a layer to be able to tell them how far to go in. Or if they say that it needs to be visible at a certain scale I can quickly make the change rather than educated guessing. Is there another way to accomplish this goal?
Thanks,
Brandon
Brandon,
You could create a widget and then use the following to get the map scale:
esri/geometry/scaleUtils | API Reference | ArcGIS API for JavaScript
Here you can learn how to build a widget:
Naming conventions—Web AppBuilder for ArcGIS | ArcGIS
Hope this helps!
Tim
I Would like to see this as well.
since we have to use a Basemap From AGOL, and I'm assuming this is always tiled and therefore has the scales set, is there maybe a way to grab apnd display without a separate widget? Maybe a tweak to the current on?
As for zooming to a set scale....I know if flex there was a way to get the more detailed (older style) zoom slider. Is therea way to do that? (Not at a place I can test right now)
Rebecca,
good idea. You should be able to just add it to the current scale widget.
Tim
Tim,
Am I understanding your reply that instead of building a new custom widget I could just modify the code for the scalebar widget using the api reference you sent previously? If so this is something I could take a look at. I've been trying to find an approachable project related to the api.
Thanks,
Brandon
Thanks Tim!
Looks great to me. My only critique would be that when it first loads it says "Your Scale". Is that because my default scale is in between the esri default scales?