10-16-2017 11:56 AM
Is there a way to clear the redline shapes made when using the Measure Distance and Measure Area tools on the sdk tool bar other than using the Clear Map tool bar command?
If i use $GP.map.draw.clear(); it hides the black text with the Distance and Area measurents but not the line or polygon that was drawn.
I would like to add the functionality of the Clear Map tool bar command to a custom tool bar command that i have written which uses $GP.map.draw to draw circles and lines for spatial queries. With that command, doing $GP.map.draw.clear() clears the black measurement text and the redline circles and lines that were drawn for the custom command but not the redline line or area shape drawn for the measurement commands.
Solved! Go to Solution.
10-17-2017 06:45 AM
Hi Jane,
The measurements are not part of the current SDK. From my POV, you have basically two options:
1) Find and delete the generated SVG <path ...> for the measurements in the DOM, which can be a bit tricky.
2) Create a Development ticket asking for enabling Measurement tools in the SDK.
Regards,
Jan
10-17-2017 12:15 PM
Thanks - With the SDK you can measure a distance or area. The measurements are hidden when you do a $GP.map.draw.clear but the red lining is not. However the redlining for $GP.map.draw in my custom command IS erased if I do a $GP.map.draw.clear. I would like one set of code to clear both types of redlining as well as the black text measurements.
10-17-2017 06:47 PM
Hi geoquery, you could try to delete the shapes created by the Measurements tab's buttons using the function below:
$event.notify("measureClear",{});
Or you could expand the API following the same idea:
API.js:
(...) E_SELECTEDFEATURES_CHANGED = "selectedFeaturesChanged", E_MEASURE_CLEAR = "measureClear", // portal GP_INTERNAL = "$GP.internal", (...) /** * Clears measurement geometries */ gp.map.measure = { clear : function(config, callback) { config = config || {}; getPortalObj(P_EVENT).notify(E_MEASURE_CLEAR, {}); fire(F_SUCCESS, callback, { success: true }); } } (...)
Cheers,
Hugo.
10-18-2017 08:37 AM
Thanks very much.
I replaced the default Map Clear command bar tool with one that had:
$GP.Map.Clear;
$event.notify("measureClear",{});
and now both the measurement information and the custom icon redlining are cleared by Map Clear command.
02-27-2019 06:58 PM
@halberti , how about just to clear the measurement drawing & result, but not the redlining (for e.g. draw a random circle)?
02-27-2019 09:36 PM
I'm not aware of a simple way to toggle the measurements, but you can draw a circle without them
You can check the "draw.circle" at https://hgdsupport.hexagongeospatial.com/API/WebGIS/Portal_SDK/16/04/#!/api/$GP.map.draw
03-11-2019 05:22 PM
This is my solution, to clear the measurement drawings & results:
// To measure a distance $GP.map.draw.path({ layerName: 'measureLyr', // draw polyline on a layer showMeasure: true, // to show the measurement }, function (r) { // put whatever actions }); // Create a button to clear the measurements $GP.map.draw.clear({ layerName: "measureLyr" });
So that any redlining will not be erased too. To erase the redlining simply use the $GP.map.draw.clear();