<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to draw a polyline displaying the shortest distance between two features in ArcGIS API for Silverlight Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307362#M7923</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a situation where I need to select 2 features on the map, get the shortest distance between these 2 features, and then programmatically draw a polyline showing the shortest path between the features. The features can be of any type.&amp;nbsp; I'm currently able to select the features and then get the shortest distance value using the geometry task.&amp;nbsp; I cannot seem to find a way to draw the polyline connecting the features however; anyone know how to do this?&amp;nbsp;&amp;nbsp; Any help would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TIA,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Todd&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 19 Apr 2011 16:32:23 GMT</pubDate>
    <dc:creator>tandrews</dc:creator>
    <dc:date>2011-04-19T16:32:23Z</dc:date>
    <item>
      <title>How to draw a polyline displaying the shortest distance between two features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307362#M7923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi All,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a situation where I need to select 2 features on the map, get the shortest distance between these 2 features, and then programmatically draw a polyline showing the shortest path between the features. The features can be of any type.&amp;nbsp; I'm currently able to select the features and then get the shortest distance value using the geometry task.&amp;nbsp; I cannot seem to find a way to draw the polyline connecting the features however; anyone know how to do this?&amp;nbsp;&amp;nbsp; Any help would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;TIA,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Todd&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Apr 2011 16:32:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307362#M7923</guid>
      <dc:creator>tandrews</dc:creator>
      <dc:date>2011-04-19T16:32:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to draw a polyline displaying the shortest distance between two features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307363#M7924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you looked at these SDK samples? &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Routing"&gt;http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#Routing&lt;/A&gt;&lt;SPAN&gt; (under Network)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 19 Apr 2011 20:46:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307363#M7924</guid>
      <dc:creator>JenniferNery</dc:creator>
      <dc:date>2011-04-19T20:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to draw a polyline displaying the shortest distance between two features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307364#M7925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well if you already have the polyline then you have some of this done already. this is an example of what it would take to build a polyline from nothing and add it to the map.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
// What my symbol looks like
Symbols.SimpleLineSymbol symbol = new ESRI.ArcGIS.Client.Symbols.SimpleLineSymbol()
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Color = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Blue),
 Style = Symbols.SimpleLineSymbol.LineStyle.Solid,&amp;nbsp;&amp;nbsp;&amp;nbsp; 
};

// the points that make up my shape
PointCollection pc = new PointCollection()
{
 new MapPoint(0,0, new SpatialReference(4326)), // first point in line
 new MapPoint(1,1, new SpatialReference(4326)), // second point in line
};

Polyline polyline = new Polyline()
{&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
 // don't for get to let the map know what spatial reference this is
 SpatialReference = new SpatialReference(4326) 
};
polyline.Paths.Add(pc);
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
Graphic g = new Graphic()
{
 Symbol = symbol, // add my symbol to my graphic
 Geometry = polyline // add my geometry to my graphic
};

GraphicsLayer graphicLayer = new GraphicsLayer();
graphicLayer.Graphics.Add(g);
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:43:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307364#M7925</guid>
      <dc:creator>ChristopherHill</dc:creator>
      <dc:date>2021-12-11T14:43:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to draw a polyline displaying the shortest distance between two features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307365#M7926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Craete a stored procedure and handle this in SQL server and display the result in the Silverlight UI graphics layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;declare @g1 geometry,@g2 geometry,@dist float,@gp1 geometry,@gp2 geometry&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;begin&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select @g1=shape from table1 OBJECTID=3;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select @g2=shape from table2 where OBJECTID=2;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;SELECT @dist=@g1.STDistance(@g2);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select @gp1=@g1.STBuffer(@dist).STIntersection(@g2);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;select @gp2=@g2.STBuffer(@dist).STIntersection(@g1);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;print 'Point1:'+convert(varchar(max),@gp1)+' Point2:'+convert(varchar(max),@gp1)+'Distance:'+convert(varchar(max),@dist)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;end;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Apr 2011 16:56:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307365#M7926</guid>
      <dc:creator>YamunadeviRathinasamy</dc:creator>
      <dc:date>2011-04-20T16:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to draw a polyline displaying the shortest distance between two features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307366#M7927</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yamuna, Thank you, currently pursuing that possibility, looks promising &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jennifer,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have reviewed those samples but thus far I've had no success employing this in my scenario.&amp;nbsp; I'm hoping that someone can help me to understand why the following simple example returns no results.&amp;nbsp; To summarize I have 1 graphics layer, I'm adding 2 points to it, and then trying to use the route task to trace the shortest distance between these features.&amp;nbsp; My routeTask_SolveCompleted event handler fires on completion without error but &lt;/SPAN&gt;&lt;STRONG&gt;e.Results is empty&lt;/STRONG&gt;&lt;SPAN&gt;.&amp;nbsp; What am I missing here?&amp;nbsp; Is it plausible to use this route task to accomplish this or am I barking up the wrong tree?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;//Clear graphics layer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;glMeasureFeatureDistance.ClearGraphics();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//Create map points:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MapPoint mpBegin = new MapPoint(3231948.89, 1740328.161);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;MapPoint mpEnd = new MapPoint(3231928.299, 1736971.88);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//Create first graphic, set geometry, set symbol, add to graphics layer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Graphic graphic = new Graphic();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;graphic.Geometry = mpBegin;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;graphic.Symbol = Measurehelp.SetSymbolSettings("Point");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;glMeasureFeatureDistance.Graphics.Add(graphic);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//Create second graphic, set geometry, set symbol, add to graphics layer:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;graphic = new Graphic();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;graphic.Geometry = mpEnd;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;graphic.Symbol = Measurehelp.SetSymbolSettings("Point");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;glMeasureFeatureDistance.Graphics.Add(graphic);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//Create route task, set url, set event handlers:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RouteTask routeTask = new RouteTask();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&lt;SPAN&gt;routeTask.Url = "&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://insert_IP/ArcGIS/rest/services/Base_Map/MapServer" rel="nofollow" target="_blank"&gt;http://insert_IP/ArcGIS/rest/services/Base_Map/MapServer&lt;/A&gt;&lt;SPAN&gt;";&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;routeTask.SolveCompleted += new EventHandler&amp;lt;RouteEventArgs&amp;gt;(routeTask_SolveCompleted);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;routeTask.Failed += new EventHandler&amp;lt;TaskFailedEventArgs&amp;gt;(routeTask_Failed);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//Create routeparameters, set properties:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;RouteParameters routeParameters = new RouteParameters();&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;routeParameters.ReturnRoutes = true;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;routeParameters.Stops = glMeasureFeatureDistance;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;//Call route task:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;routeTask.SolveAsync(routeParameters);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 21 Apr 2011 21:10:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307366#M7927</guid>
      <dc:creator>tandrews</dc:creator>
      <dc:date>2011-04-21T21:10:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to draw a polyline displaying the shortest distance between two features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307367#M7928</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt; &lt;BR /&gt;What am I missing here? &lt;BR /&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;You have to set the spatial reference of your 2 points (mpBegin and mpEnd) since, obviously, it's not geographical coordinates.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Is it plausible to use this route task to accomplish this or am I barking up the wrong tree?&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt;I am not sure of what you have to do exactly, but using the route task you will find the shortest path between 2 points using existing roads.&amp;nbsp; Has your shortest path to take care of the roads?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Apr 2011 15:27:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307367#M7928</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2011-04-26T15:27:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to draw a polyline displaying the shortest distance between two features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307368#M7929</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi dbroux,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, the SR is set correctly.&amp;nbsp; I have no roads and I do not have Network Analyst.&amp;nbsp; I'm very confident at this point that I am indeed looking at the route task in a wishful manner.&amp;nbsp; Putting the route task aside I am back to the original query:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know how to draw a polyline displaying the shortest distance between two features???&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using the geometry task 'DistanceAsync' method to GET the distance but I cannot determine where the start and end points are as the method does not return these values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Todd&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Apr 2011 16:25:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307368#M7929</guid>
      <dc:creator>tandrews</dc:creator>
      <dc:date>2011-04-26T16:25:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to draw a polyline displaying the shortest distance between two features</title>
      <link>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307369#M7930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Putting the route task aside I am back to the original query:&lt;BR /&gt; &lt;BR /&gt;Does anyone know how to draw a polyline displaying the shortest distance between two features???&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I don't know and it doesn't look simple to me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yamuna idea (use SQL server to do it) looks promising but I never tested that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Another options might be to write geometry code at the client side (not that easy), or write a web service doing it with ArcObjects or perhaps a GP tools could do it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately I can't help you more. Sorry.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hopefully somebody else will have better ideas....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Apr 2011 16:57:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-silverlight-questions/how-to-draw-a-polyline-displaying-the-shortest/m-p/307369#M7930</guid>
      <dc:creator>DominiqueBroux</dc:creator>
      <dc:date>2011-04-26T16:57:51Z</dc:date>
    </item>
  </channel>
</rss>

