Select to view content in your preferred language

Measurement in 2D sample - Disable the Info window and configure utilized units in code ?

524
2
09-05-2023 11:22 PM
AllisonRobertson
New Contributor

Hi,
Using the DistanceMeasurement2D and AreaMeasurement2D widgets, as represented in the "Measurement in 2D" sample (at https://developers.arcgis.com/javascript/latest/sample-code/widgets-measurement-2d/), is it possible to configure the widgets to disable the display of the info window, and hard code the unit of measurement used by the respective widgets?
Version 3.x of the ArcGIS JavaScript API allowed this, as discussed here : https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/js-api-measurement-widget-in-draw...
... However the available properties and methods for the DistanceMeasurement2D and AreaMeasurement2D widgets, at Javascript 4.x, apparently do not. Please let me know if you are aware of how this may be done.

Thanks for any advice on this ...
Regards,
Allison

0 Kudos
2 Replies
BhavinSanghani
Frequent Contributor

@AllisonRobertson Did you try popupEnabled: false with the MapView to disable the popup? MeasurementViewModel has view property that can give you MapView instance.

0 Kudos
AllisonRobertson
New Contributor

Hi @BhavinSanghani 
Thank-you very much for your reply.
I tried adding popupEnabled: false to the MapView constructor, but that did not cause a change in behaviour ie. the popup still shows at runtime when using the measurement2D tool, when the view has the following constructor code

       const view = new MapView({
              container: "viewDiv",
              map: map,
              center: [144.95, -37.8],
              zoom: 10,
              popupEnabled: false
       });
 
I also (optimistically) tried adding it to the function that runs once the view is loaded (included below), however this also appears to have no affect at runtime.
       view.when(function() {
          view.popupEnabled = false;    
        });
 
Any further advice on this topic greatly appreciated, as I would have thought the subject functionality should be possible 🙂
Thanks again,
Allison
0 Kudos