11How-to configure the Measure tool
22=================================
33
4- The measure tool is managed as a part of the ServiceManager component.
5- Therefore, all the options for the measure tool are passed in as options
6- to the ServiceManger component when it's added to the application.
4+ The measure tool is configured in two places:
5+
6+ #. The application-level ``measure `` configuration object controls which
7+ units are offered and whether the on-map annotations start on or off.
8+ #. The ServiceManager component's ``measureToolOptions `` control the
9+ point-coordinate projections and the initially selected units.
10+
11+ Application measure configuration
12+ ---------------------------------
13+
14+ Pass a ``measure `` object when creating the application to control the
15+ units offered in the tool and the default annotation behavior:
16+
17+ .. code :: javascript
18+
19+ var app = new gm3.Application ({
20+ mapserver_url: CONFIG .mapserver_url ,
21+ mapfile_root: CONFIG .mapfile_root ,
22+ measure: {
23+ lengthUnits: [" m" , " km" , " ft" , " mi" , " ch" , " r" ],
24+ areaUnits: [" m" , " km" , " ft" , " mi" , " a" , " h" ],
25+ showMeasureLabels: true
26+ }
27+ });
28+
29+ - ``lengthUnits `` is the list of length units offered in the tool. Valid
30+ values are:
31+
32+ - ``m `` for meters.
33+ - ``km `` for kilometers.
34+ - ``ft `` for feet.
35+ - ``mi `` for miles.
36+ - ``ch `` for chains.
37+ - ``r `` for rods.
38+
39+ The default is ``["m", "km", "ft", "mi", "ch"] ``.
40+
41+ - ``areaUnits `` is the list of area units offered in the tool. Valid
42+ values are:
43+
44+ - ``m `` for square meters.
45+ - ``km `` for square kilometers.
46+ - ``ft `` for square feet.
47+ - ``mi `` for square miles.
48+ - ``a `` for acres.
49+ - ``h `` for hectares.
50+
51+ The default is ``["m", "km", "ft", "mi", "a", "h"] ``.
52+
53+ - ``showMeasureLabels `` is a boolean that sets the *initial * state of
54+ the on-map measure annotations. ``true `` (the default) shows them,
55+ ``false `` hides them until the user turns them on with the labels
56+ button. See :doc: `Turning off measure annotations by default
57+ <disable-measure-labels>` for details.
58+
59+ .. note ::
60+
61+ Length and area units are paired: selecting a length unit
62+ automatically selects a complementary area unit (and vice versa).
63+ Chains and rods both pair with acres, following surveyor convention.
64+
65+ ServiceManager options
66+ ----------------------
67+
68+ The measure tool is rendered by the ServiceManager component, so the
69+ point-coordinate and initial-unit options are passed in as
70+ ``measureToolOptions `` when the ServiceManager is added to the
71+ application.
772
873Here's the example from the demo:
974
@@ -20,14 +85,10 @@ Here's the example from the demo:
2085 that is defined the same as with the :doc: `Coordinate
2186 Display <coordinate-display>`. When a user clicks on a point on
2287 the map, the point will be shown in all of the defined projections.
23- - ``initialUnits `` is one of:
24- - ``m `` for meters.
25- - ``km `` for kilometers.
26- - ``ft `` for feet (this is the default).
27- - ``mi `` for miles.
28- - ``ch `` for chains.
29- - ``a `` for acres.
30- - ``h `` for hectares.
88+ - ``initialUnits `` overrides the initially selected length and area
89+ units when the tool opens. It is a single unit code from the
90+ ``lengthUnits ``/``areaUnits `` lists above (for example ``m ``, ``ft ``,
91+ or ``ch ``).
3192
3293Example of setting the default units to meters
3394----------------------------------------------
0 commit comments