1

I use C# for creating an AddIn for ArcGIS Pro 3.1. One of the features of the AddIn is to jump to a position.

var wgs84 = SpatialReferences.WGS84;
var pointInWGS84 = MapPointBuilder.CreateMapPoint(Convert.ToDouble(result.lon), Convert.ToDouble(result.lat), wgs84);

var currentSystem = MapView.Active.Camera.SpatialReference;

MapPoint pointInCurrentSystem = (MapPoint)GeometryEngine.Instance.Project(pointInWGS84, currentSystem);

const int DefaultScaleAfterZoom = 5000;
var camera = new Camera(pointInCurrentSystem.X, pointInCurrentSystem.Y, DefaultScaleAfterZoom, MapView.Active.Camera.Heading);

MapView.Active.ZoomToAsync(camera, TimeSpan.Zero);

        

Now I want to set a temporary marker on that position. Is there some kind of "temporary" layer, which is made for temporary marking things or do I have to use a regular layer?

I want to avoid, that this marker has any effect on the layer list or something else the user can configure.

2 Answers 2

2

I think that would be possible by calling one of the AddOverlay() overloads on the mapview. The graphic will be visible until you dispose it.

1

With the help of @Berend's answer, I found this example in the offical documentation: https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic27596.html

So I finally used this code to draw a temporary circle at a specific map point:

    private async void DrawMarker(MapPoint pointInCurrentSystem)
    {
        var mapView = MapView.Active;
        if (mapView == null)
            return;

        m_marker = await QueuedTask.Run(() =>
        {
            return mapView.AddOverlay(pointInCurrentSystem,
                SymbolFactory.Instance.ConstructPointSymbol(
                        ColorFactory.Instance.GreyRGB, 20.0, SimpleMarkerStyle.Circle).MakeSymbolReference());
        });

    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.