Click feature and get route from current location

768
4
Jump to solution
02-09-2021 04:10 AM
EricAtkinson1
New Contributor III

Hey all,

I've been searching everywhere to find an example of clicking on a feature and getting a route from current location. Any help would be greatly appreciated. I am using QML and Runtime 100.8. I do know the nearby sample does have that capability but having trouble finding the source code due to all the other capabilities.

Thanks in advance,

Eric

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JoeHunt1
New Contributor II

HI Eric,

I give the user the choice of starting navigation from any point or current location.  The user selects from the buttons.

JoeHunt1_0-1612905721497.png

Here is the code that sets the current location as the starting point and places a graphic.

stop1Geometry=RT.ArcGISRuntimeEnvironment.createObject("Point", {x: mapView.locationDisplay.location.position.x, y: mapView.locationDisplay.location.position.y, spatialReference: RT.SpatialReference.createWgs84()});
var simpleMarker1 = RT.ArcGISRuntimeEnvironment.createObject("SimpleMarkerSymbol", {style: RT.Enums.SimpleMarkerSymbolStyleCross, size: 15, color: "green"});
var graphic1 = RT.ArcGISRuntimeEnvironment.createObject("Graphic", {symbol: simpleMarker1, geometry: stop1Geometry});


graphicsOverlay.graphics.append(graphic1)

Hope this helps.

Joe

 

View solution in original post

0 Kudos
4 Replies
JoeHunt1
New Contributor II

HI Eric,

I give the user the choice of starting navigation from any point or current location.  The user selects from the buttons.

JoeHunt1_0-1612905721497.png

Here is the code that sets the current location as the starting point and places a graphic.

stop1Geometry=RT.ArcGISRuntimeEnvironment.createObject("Point", {x: mapView.locationDisplay.location.position.x, y: mapView.locationDisplay.location.position.y, spatialReference: RT.SpatialReference.createWgs84()});
var simpleMarker1 = RT.ArcGISRuntimeEnvironment.createObject("SimpleMarkerSymbol", {style: RT.Enums.SimpleMarkerSymbolStyleCross, size: 15, color: "green"});
var graphic1 = RT.ArcGISRuntimeEnvironment.createObject("Graphic", {symbol: simpleMarker1, geometry: stop1Geometry});


graphicsOverlay.graphics.append(graphic1)

Hope this helps.

Joe

 

0 Kudos
EricAtkinson1
New Contributor III

Thanks Joe that helped alot. I have only had experience with WAB and Dashboards so this is all pretty new to me. I am trying to use this route URL  https://route.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World but it does not seem to be working and am wondering if I need to put in a API key?

 

cheers,

0 Kudos
JoeHunt1
New Contributor II

I have never used that service and I couldn't access it.  We have our own network dataset that we use.

0 Kudos
EricAtkinson1
New Contributor III

Cheers Joe,  I’ll hunt down if we have our own service.

Eric

0 Kudos