Can I display current scale in web app builder application?

14459
36
Jump to solution
02-20-2015 05:07 AM
BrandonKeinath1
Occasional Contributor III

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

1 Solution

Accepted Solutions
TimWitt2
MVP Regular Contributor

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.

View solution in original post

36 Replies
TimWitt2
MVP Regular Contributor

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

TimWitt2
MVP Regular Contributor

Looking at it, it seems buggy to me.

0 Kudos
BrandonKeinath1
Occasional Contributor III

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

0 Kudos
TimWitt2
MVP Regular Contributor

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

0 Kudos
RebeccaStrauch__GISP
MVP Esteemed Contributor

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)

TimWitt2
MVP Regular Contributor

Rebecca,

good idea. You should be able to just add it to the current scale widget.

Tim

0 Kudos
BrandonKeinath1
Occasional Contributor III

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

0 Kudos
TimWitt2
MVP Regular Contributor

Brandon,

Here is something I have prepared quickly (It is not the best looking).

Just replace the coordinate folder in your widget folder with the attached file.

You should see the scale below the map coordinates when you zoom/pan.

Let me know if it works.

Tim

BrandonKeinath1
Occasional Contributor III

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?

Capture.JPG

0 Kudos