Hexagon Geospatial
MENU

Developer Discussions

Discuss topics with other Hexagon Geospatial Power Portfolio developers and experts to get the most out of our products.
Showing results for 
Search instead for 
Do you mean 
Reply
Regular Contributor
Posts: 248
Registered: ‎05-01-2016
Accepted Solution

$GP.map.draw.clear();

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.

 

Technical Evangelist
Posts: 1,118
Registered: ‎09-11-2015

Re: $GP.map.draw.clear();

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

Jan Neumann
Post Sales Engineer Web Applications
Hexagon Geospatial

Regular Contributor
Posts: 248
Registered: ‎05-01-2016

Re: $GP.map.draw.clear();

measure.png 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.

Highlighted
New Contributor
Posts: 4
Registered: ‎12-07-2015

Re: $GP.map.draw.clear();

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.

Regular Contributor
Posts: 248
Registered: ‎05-01-2016

Re: $GP.map.draw.clear();

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.

Occasional Contributor
Posts: 9
Registered: ‎10-16-2016

Re: $GP.map.draw.clear();

@halberti , how about just to clear the measurement drawing & result, but not the redlining (for e.g. draw a random circle)?

New Contributor
Posts: 4
Registered: ‎12-07-2015

Re: $GP.map.draw.clear();

I'm not aware of a simple way to toggle the measurements, but you can draw a circle without them Smiley Wink

 

You can check the "draw.circle" at https://hgdsupport.hexagongeospatial.com/API/WebGIS/Portal_SDK/16/04/#!/api/$GP.map.draw

 

Dd
Occasional Contributor
Posts: 14
Registered: ‎11-05-2017

Re: $GP.map.draw.clear();

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();

 

Do you need immediate support?
Please submit a Ticket through our
Development Ticket Portal.