AnsweredAssumed Answered

Polyline not crossing international Dateline

Question asked by aflythen on Jul 22, 2019
Latest reply on Jul 23, 2019 by aflythen

Hello,

I have a simple WPF .NET application using the v100.5 ESRI ArcGISRuntime that creates a polyline with two points, one in San Diego, California, the other in Kwajalein Atoll on an ESRI basemap. The lat/longs are entered in WGS84. I found this article 

https://community.esri.com/thread/118744 and tried that solution but the line never crosses the International Dateline, instead it takes the long way around the world (See attached PNG). Here is the code:

 

using Esri.ArcGISRuntime.Geometry;
using Esri.ArcGISRuntime.Mapping;
using Esri.ArcGISRuntime.Symbology;
using Esri.ArcGISRuntime.UI;
using System;
using System.Windows;
using System.Windows.Controls;

namespace ESRI_Test
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
// Graphics overlay to display the graphics.
private GraphicsOverlay _graphicsOverlay;
private Graphic _countryBorderPolylineGraphic;

public MainWindow()
{
InitializeComponent();
// Create a map with a topographic basemap.
Map newMap = new Map(BasemapType.DarkGrayCanvasVector, 21.339723, -157.945774, 2);

 

// Assign the map to the MapView.
MyMapView.Map = newMap;
var test = newMap.SpatialReference;

 

// Create a graphics overlay to hold the various graphics.
_graphicsOverlay = new GraphicsOverlay();

// Add the created graphics overlay to the MapView.
MyMapView.GraphicsOverlays.Add(_graphicsOverlay);


// Add the map points to the point collection.
PointCollection newborderCountryPointCollection = new PointCollection(SpatialReferences.WebMercator)
{
(MapPoint)GeometryEngine.NormalizeCentralMeridian((MapPoint) GeometryEngine.Project(new MapPoint(-157.945774, 21.339723, SpatialReferences.Wgs84), SpatialReferences.WebMercator)),
(MapPoint)GeometryEngine.NormalizeCentralMeridian((MapPoint) GeometryEngine.Project(new MapPoint(167.726017, 8.719545, SpatialReferences.Wgs84), SpatialReferences.WebMercator))
};

// Create a polyline geometry from the point collection.
Polyline newborderCountryPolyline = new Polyline(newborderCountryPointCollection);

// Create a simple line symbol
SimpleLineSymbol newcountryBorderSimpleLineSymbol = new SimpleLineSymbol(SimpleLineSymbolStyle.Dot, System.Drawing.Color.Blue, 5);

// Create the graphic - comprised of a polyline shape and line symbol.
Graphic _newcountryBorderPolylineGraphic = new Graphic(newborderCountryPolyline, newcountryBorderSimpleLineSymbol);
_graphicsOverlay.Graphics.Add(_newcountryBorderPolylineGraphic);
}
}
}

 

Any thoughts what I am missing? Or doing wrong?

 

Thanks in advance for the help

Attachments

Outcomes