Select to view content in your preferred language

Directions from two points

2288
9
09-30-2011 08:46 AM
JayKappy
Frequent Contributor
I am looking at a sample online of an app that takes and address and shows the user that location as well as the another location (polling location).....I can do this in my app....but what my app is not doing is showing the directions, distance and Total drive time.

http://localgovtemplates2.esri.com/ElectionPollingPlace/default.htm

How do you do this...are there any examples out there that show this functionality....I can do everythign else but would be most appeciative if you could point me in the direction of some exampels to return directions.

Thanks in advance...have a great weekend
0 Kudos
9 Replies
JayKappy
Frequent Contributor
I saw the download but wondering if anyone had examples in .net not javascript
0 Kudos
ChristopherHill
Deactivated User
0 Kudos
JayKappy
Frequent Contributor
THanks Christopher....actually found that just a bit ago....thanks for your responce....
help is appreciated.
0 Kudos
JayKappy
Frequent Contributor
Any thoughts....I am using this example and CANNOT get the start and endpoint symbols to show up...I can get the route to show up fine....but not the points...
confused here....
http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#RoutingDirections

The graphics layer exists in my map...can a graphics layer have point and lines in it?  The example online has the points and lines beign assigned to the same graphics layer "MyRouteGraphicsLayer"

Confused.

Additionally I had to add code to the SYMBOL in the routeTask_SolveCompleted Sub

WAS THIS: not working
graphicsLayer.Graphics.Add(New Graphic() With {.Geometry = _directionsFeatureSet.MergedGeometry, .Symbol = RouteSymbol})

CHANGED TO THIS: now working
graphicsLayer.Graphics.Add(New Graphic() With {.Geometry = _directionsFeatureSet.MergedGeometry, .Symbol = LayoutRoot.Resources("RouteSymbol")
})

But still dont understand why I cant see the start and end graphics......thanks
0 Kudos
JayKappy
Frequent Contributor
Any thoughts why I cant get the start and end point to show up....
Can I place points and lines in the same graphic layer?
0 Kudos
DominiqueBroux
Esri Frequent Contributor

Can I place points and lines in the same graphic layer?

Yes, you can. This sample is exactly doing what you are looking for. Please look at it.

why I cant get the start and end point to show up....

Without any info, I can just guess that you have a marker symbol issue as it seems you had with your route symbol.
Check with the debugger that your symbol is not null (and is a markersymbol).
0 Kudos
JayKappy
Frequent Contributor
This is what I have.....is the syntax incorrect on the graphic symbol?  I know that it can see the Marker symbols as it is drawing the line symbol right below it...it has to be syntax

Thanks for yoru thoughts

VB
graphicLocation.Symbol = TryCast(LayoutRoot.Resources("FromSymbol"), Symbols.Symbol)

XAMl
    <Grid x:Name="LayoutRoot" Background="{StaticResource BaseColor}">
        <Grid.Resources>

            <!-- NEW DIRECTIONS STUFF -->
            <esri:SimpleMarkerSymbol x:Key="FromSymbol" Size="15" Style="Circle" Color="#9900FF00" />
            <esri:SimpleMarkerSymbol x:Key="ToSymbol" Size="15" Style="Circle" Color="#99FF0000" />
            <esri:SimpleLineSymbol x:Key="RouteSymbol" Color="#990000FF" Width="5"/>
            <esri:SimpleLineSymbol x:Key="SegmentSymbol" Color="#99FF0000" Width="8"/>
            <!-- END DIRECTIONS STUFF -->

I also tried usign other defualt marker symbols that I am usign elsewhere..nothing....but am returning the line...hmmmm
0 Kudos
JayKappy
Frequent Contributor
Funny I messagebox a count and I am getting 11....dosent seem right...well maybe the geocoder is grabbing 11 and then grabbing the first with this: Dim address As AddressCandidate = e.Results(0)


Private Sub locator_AddressToLocationsCompleted(ByVal sender As Object, ByVal e As AddressToLocationsEventArgs)
Dim graphicsLayer As GraphicsLayer = (TryCast(MyMap.Layers("MyRouteGraphicsLayer"), GraphicsLayer))
If e.Results.Count > 0 Then
Dim address As AddressCandidate = e.Results(0)
Dim graphicLocation As New Graphic() With {.Geometry = address.Location}
graphicLocation.Attributes.Add("address", address.Address)
graphicLocation.Attributes.Add("score", address.Score)

_stops.Add(graphicLocation)

MessageBox.Show("Count")
MessageBox.Show(e.Results.Count)


If CStr(e.UserState) Is "from" Then
MessageBox.Show("From")
graphicLocation.Symbol = TryCast(LayoutRoot.Resources("FromSymbol"), Symbols.Symbol)
'graphicLocation.Symbol = TryCast(LayoutRoot.Resources("DefaultMarkerSymbol"), Symbols.Symbol)
'Geocode to address
_locator.AddressToLocationsAsync(ParseAddress(ToTextBox.Text), "to")
Else


I then tried to eliminate the If then by doign this....and still nothing....

Dim graphicLocation As New Graphic() With {.Geometry = address.Location, .Symbol = LayoutRoot.Resources("FromSymbol")}
0 Kudos
HoudiniSutherland
Emerging Contributor
At least you guys have a result set working with. Me? I am trying to find a service that returns directions for the counrty of Jamaica. Is there such a serive available? I know services exists for North America and Europe, but is there a worldwide service or something like that?
0 Kudos