Select to view content in your preferred language

MapTool.UpdateOverlay - No Overload with referenceScale parameter

1972
6
Jump to solution
04-18-2021 12:30 PM
ChristianSchneider1
Emerging Contributor

Hi,

I have written a custom maptool where I use overlays to show graphic information on a map view.

In the OnToolActivateAsync I call the AddOverlay method to add the graphic overlay and in my OnToolMouseMove I call the UpdateOverlay method. To this point, everything worked fine.

But know I had the requirement that the overlay symbol should scale according to some reference scale.

In the API there is a overload for the AddOverlay method where I can set the reference scale:
https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/index.html#topic27602.html

But there is no similar overload for the UpdateOverlay method!

The result is now that when the tool is activated, the graphic is scaled accoring to my reference scale but as I move the mouse, the reference scale setting is lost and the overlay graphics becomes bigger.

I helped myself with destroying the overlay with Dispose and calling AddOverlay with the reference scale parameter in the OnToolMouseMove but that causes a slight flickering of my overlay graphic.

Is there a better way to do this?

Why is there no overload for UpdateOverlay with a reference scale parameter?

0 Kudos
2 Solutions

Accepted Solutions
NarelleChedzey
Esri Contributor

Hi Christian, 

 

Unfortunately I don't think there is a better way of accomplishing what you're attempting to do right now. 

 

I'll add an issue to include an overload for UpdateOverlay on the MapTool and the MapView objects to include the reference scale parameter.  These will be in the next release of ArcGIS Pro.  Since 2.8 is very close to being released, these methods will be added at the 2.9 release. 

 

Thanks

Narelle

 

View solution in original post

NarelleChedzey
Esri Contributor

Hi, 

 

I wanted to confirm that an UpdateOverlay overload has been added to the MapTool and MapView classes to include a reference scale parameter at ArcGIS Pro 2.9. 

 

Regards

Narelle

View solution in original post

6 Replies
NarelleChedzey
Esri Contributor

Hi Christian, 

 

Unfortunately I don't think there is a better way of accomplishing what you're attempting to do right now. 

 

I'll add an issue to include an overload for UpdateOverlay on the MapTool and the MapView objects to include the reference scale parameter.  These will be in the next release of ArcGIS Pro.  Since 2.8 is very close to being released, these methods will be added at the 2.9 release. 

 

Thanks

Narelle

 

ChristianSchneider1
Emerging Contributor

Thank you very much Narelle!

0 Kudos
CharlesMacleod
Esri Regular Contributor

GraphicsLayer has a reference scale fyi. That is probably the better option.

Set it via the CIM. Something along the lines of.....

 

var def = graphicsLayer.GetDefinition() as CIMGraphicsLayer;

def.ReferenceScale = 1000.0; //eg 1:1000

graphicsLayer.SetDefinition(def);

0 Kudos
ChristianSchneider1
Emerging Contributor

Hey Charlie,

how do I get a reference to the graphics layer?

In my case I am just using a custom map tool where I call AddOverlay or UpdateOverlay, I did not explicitly add a graphics layer to my map. The map therefore does not contain a graphics layer in the layer enumeration and map.TargetGraphicsLayer is also null.

I guess there is some kind of hidden graphics layer where the graphics are added by the AddOverlay or UpdateOverlay methods but neither on the map nor on the cimmap I can find a possibility to get a reference to the graphics layer.

 

0 Kudos
CharlesMacleod
Esri Regular Contributor

you would need to explicitly create one (or the user could add one via the UI).

 

To add a GraphicsLayer to the map, see here:

https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-GraphicsLayers#create-graphicslayer

More details on GraphicsLayer can also be found here:

 

https://github.com/Esri/arcgis-pro-sdk/wiki/ProConcepts-GraphicsLayers

 

NarelleChedzey
Esri Contributor

Hi, 

 

I wanted to confirm that an UpdateOverlay overload has been added to the MapTool and MapView classes to include a reference scale parameter at ArcGIS Pro 2.9. 

 

Regards

Narelle