Geographic coordinate to MapPoint

582
5
01-23-2017 10:57 AM
Highlighted
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

Reply
0 Kudos
5 Replies
Highlighted
Esri 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...?

Reply
0 Kudos
Highlighted
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.

Reply
0 Kudos
Highlighted
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);

Reply
0 Kudos
Highlighted
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.

Reply
0 Kudos
Highlighted
Esri 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));

});