MapPoint pt1 = MapPointBuilderEx.CreateMapPoint(1.0, 1.0);
MapPoint pt2 = MapPointBuilderEx.CreateMapPoint(2.0, 2.0);
MapPoint pt3 = MapPointBuilderEx.CreateMapPoint(4.0, 2.0);
//
// pt and pt
//
double d = GeometryEngine.Instance.Distance(pt1, pt2); // d = Math.Sqrt(2)
//
// pt and multipoint
//
List<MapPoint> multiPts = new List<MapPoint>();
multiPts.Add(pt2);
multiPts.Add(pt3);
Multipoint multiPoint = MultipointBuilderEx.CreateMultipoint(multiPts);
d = GeometryEngine.Instance.Distance(pt1, multiPoint); // d = Math.Sqrt(2)
//
// pt and envelope
//
Envelope env = EnvelopeBuilderEx.CreateEnvelope(pt1, pt2);
d = GeometryEngine.Instance.Distance(pt1, env); // d = 0
//
// pt and polyline
//
List<MapPoint> polylinePts = new List<MapPoint>();
polylinePts.Add(MapPointBuilderEx.CreateMapPoint(2.0, 1.0));
polylinePts.Add(pt2);
Polyline polyline = PolylineBuilderEx.CreatePolyline(polylinePts);
d = GeometryEngine.Instance.Distance(pt1, polyline); // d = 1.0
//
// pt and polygon
//
Envelope env2 = EnvelopeBuilderEx.CreateEnvelope(MapPointBuilderEx.CreateMapPoint(3.0, 3.0), MapPointBuilderEx.CreateMapPoint(5.0, 5.0));
Polygon poly = PolygonBuilderEx.CreatePolygon(env2);
d = GeometryEngine.Instance.Distance(pt1, poly); // d = Math.Sqrt(8)
//
// envelope and polyline
//
d = GeometryEngine.Instance.Distance(env, polyline); // d = 0
//
// polyline and polyline
//
List<MapPoint> polylineList = new List<MapPoint>();
polylineList.Add(MapPointBuilderEx.CreateMapPoint(4, 3));
polylineList.Add(MapPointBuilderEx.CreateMapPoint(4, 4));
Polyline polyline2 = PolylineBuilderEx.CreatePolyline(polylineList);
d = GeometryEngine.Instance.Distance(polyline, polyline2); // d = Math.Sqrt(5)
//
// polygon and polygon
//
Polygon poly2 = PolygonBuilderEx.CreatePolygon(env);
d = GeometryEngine.Instance.Distance(poly, poly2); // d = Math.Sqrt(2)