Geographic coordinate to MapPoint

1841
5
01-23-2017 10:57 AM
andresarias
New Contributor II

Hello, I'm trying to locate on the map a geographic coordinate. I haven't been able to find a ProSnippet, arcgis pro sdk community samples or any other example that can give me clues on how to do it.#arcgisprosdk #csharp #addin #coordinate#mappoint

0 Kudos
5 Replies
CharlesMacleod
Esri Regular Contributor

Hi Andreas, can you be more specific please? You want to....zoom, pan to the location, select something at a location, show a dot (or similar) on a map "at" the location or...?

0 Kudos
andresarias
New Contributor II

I am creating a tool that would zoom in on specific geographic points. My idea is to have the list of geographic points with their geographic coordinates which the tool should convert to the current map mappoints, but as said I'm a bit clueless on how to go about.

0 Kudos
DuaneWhistle
New Contributor

I created a MapPoint then used this code:

var coords = GeometryEngine.Project(theMapPoint, SpatialReferences.WGS84) as MapPoint; 

_pointSymbol = SymbolFactory.ConstructPointSymbol(ColorFactory.RedRGB, 6, SimpleMarkerStyle.Circle);

AddOverlayAsync(coords, _pointSymbol.MakeSymbolReference());

ActiveMapView.ZoomTo(theMapPoint);

0 Kudos
andresarias
New Contributor II

What is theMapPoint? Is it a point selected from the map? If so, that's not what I need. I need a way to convert geographic coordinates into MapPoints.

0 Kudos
CharlesMacleod
Esri Regular Contributor

Hi Andreas, might I suggest starting here:

Create MapPoint

https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Geometry#construct-a-mappoint

Projection:

https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-Geometry#project-from-wgs84-to-webmercator

Zoom, Pan, etc.

https://github.com/esri/arcgis-pro-sdk/wiki/ProSnippets-MapExploration#zoom-to-an-extent

and so, one example might be.....

QueuedTask.Run(() => {

   //Create a point

   var pt = MapPointBuilder.CreateMapPoint(x,y,SpatialReferenceBuilder.CreateSpatialReference(4326));
   //Buffer it - for purpose of zoom
   var poly = GeometryEngine.Buffer(pt, buffer_size);

   //do we need to project the buffer polygon?

   if (!MapView.Active.Map.SpatialReference.IsEqual(poly.SpatialReference)) {
       //project the polygon
       poly = GeometryEngine.Project(poly, MapView.Active.Map.SpatialReference);
    }

    //Zoom - add in a delay for animation effect
    MapView.Active.ZoomTo(poly,new TimeSpan(0, 0, 0, 3));

});