Example of use map route, drawroute, layers, geoJson

i try to use the mapViewer (webMapViewer) and his methos

addlocation and gotolocation is ok and simply

but i can’t undestand the use of drawroute using maptoute with geoJson object

then can mapviewer has a lot of layers

anyone know if there are example projects where i can see the use of geoJson, drawroute( with maproute–<geoJson object )

seems .Route return a MapRoute


There are a few ways. If you just want to show a route, set the WebMapViewer.Mode to Directions, then use WebMapViewer.AddLocation to add some route waypoints (at least two).

In View mode it works the same, but you’ll have to call WebMapViewer.DrawRoute.

You don’t really need to pass any GeoJSON unless you want to pre-compute directions and store them into a database, to save a few calls to the routing service API. In that case, as @MarkusR mentioned, you have the WebMapViewer.Route method, that will return a MapRoute object, containing the raw GeoJSON data.

1 Like

ok, i have try this code but the map show only first location (location)
and not the route


Var location As New WebMapLocation
location.Address = “Via Ticino 10 agliana 51031 pistoia”

Var location1 As New WebMapLocation
location1.Address = “Via Ticino 30 agliana 51031 pistoia”

Var location2 As New WebMapLocation
location2.Address = “Via Ticino 40 agliana 51031 pistoia”

Var location3 As New WebMapLocation
location3.Address = “Via Ticino 73 agliana 51031 pistoia”

Var r As New MapRoute

then, is there an exaustive example of all possibilities for use this component?
because the documentation is not exaustive and the example show only add location

ok, one problem is that one address and his location has null values