Adding scale text to our ArcGIS Online maps

4583
8
Jump to solution
05-23-2013 12:09 AM
TuridBrox
Occasional Contributor
Is there a way to let the viewer see scale text (i. e. "1:1000") instead of just a scale bar in ArcGIS Online maps? We are using the Basic Viewer template with some minor modifications. We would want to use metres as the unit, if possible.

Even better: is there a way to let users choose a scale by selecting from a drop-down menu, or typing the numbers?

Any hints are appreciated 🙂

Thanks,
Turid
1 Solution

Accepted Solutions
DavideLimosani
Occasional Contributor II
Is there a way to let the viewer see scale text (i. e. "1:1000") instead of just a scale bar in ArcGIS Online maps? We are using the Basic Viewer template with some minor modifications. We would want to use metres as the unit, if possible.

Even better: is there a way to let users choose a scale by selecting from a drop-down menu, or typing the numbers?

Any hints are appreciated 🙂

Thanks,
Turid


Hi,

use map.getScale();

http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/map.html#getscale

and to set the scale try something like this:

              <input id="scale"                onkeypress="keyPress(event)"               onChange="map.setExtent(esri.geometry.getExtentForScale(map, this.value.replace('.', '')));"/>  function keyPress(e) {     if (e.keyCode == 13) {         dojo.byId("scale").blur();     } }

View solution in original post

0 Kudos
8 Replies
DavideLimosani
Occasional Contributor II
Is there a way to let the viewer see scale text (i. e. "1:1000") instead of just a scale bar in ArcGIS Online maps? We are using the Basic Viewer template with some minor modifications. We would want to use metres as the unit, if possible.

Even better: is there a way to let users choose a scale by selecting from a drop-down menu, or typing the numbers?

Any hints are appreciated 🙂

Thanks,
Turid


Hi,

use map.getScale();

http://help.arcgis.com/en/webapi/javascript/arcgis/jsapi/map.html#getscale

and to set the scale try something like this:

              <input id="scale"                onkeypress="keyPress(event)"               onChange="map.setExtent(esri.geometry.getExtentForScale(map, this.value.replace('.', '')));"/>  function keyPress(e) {     if (e.keyCode == 13) {         dojo.byId("scale").blur();     } }
0 Kudos
TuridBrox
Occasional Contributor
Thanks a lot! 🙂
0 Kudos
RobertBorchert
Frequent Contributor III
do you know of any way to apply the getScale() to a label either for a feature or a Dynamic Text field in a layout
0 Kudos
DavideLimosani
Occasional Contributor II
add this and you have all in the same textbox:



function showScale() {
   
     dojo.byId("scale").value = dojo.number.format(map.getScale(), { pattern:"##,##0"});
}

    dojo.connect(map, "onZoomEnd", showScale);

0 Kudos
RobertBorchert
Frequent Contributor III
I pasted that into a text box and it shows what i pasted as the text

add this and you have all in the same textbox:
0 Kudos
DavideLimosani
Occasional Contributor II
I pasted that into a text box and it shows what i pasted as the text


mmh sorry I don't understant your problem... can you explain it better please?
0 Kudos
RobertBorchert
Frequent Contributor III
I am looking for a way to return scale in an ArcGIS session.

Possibly by putting it in a dynamic text box in layout.

Or better yet to write it into a Definition query.

The query would be something like only show this feature if the scale is less than (or greater then) the attribute (the attribute would have desired scale)

Essentially.

I have an attribute I call VisibleScale.   I populate it with scale values.  1000, 2000, 15000 etc.

The definition query would be such that if the current scale value is greater then the VisibleScale Attribute then the individual feature would not be visible.

mmh sorry I don't understant your problem... can you explain it better please?
0 Kudos
TuridBrox
Occasional Contributor
add this and you have all in the same textbox:


Thanks for the code snippet. I added this to the layout.js-file. But how do I get it to display on the map? I assume I must make some changes either in the .html-file, or one of the CSS-files?

Turid
0 Kudos