Is possibile draw a line in mapviewer (web)

I would likes draw a line ( not a route ) from position A to position b in mapviewer without using route and i canti find a method in mapviewer object (rendering = maplibre)

As of today and as far as I see, you can’t do this currently in Xojo.

You may fill a feature request to get something like this added.
Or try to do it yourself in JavaScript using the ExecuteJavaScript method and do it yourself. But for that you’d have to lookup the JavaScript APIs used there.

1 Like

Take a look at this thread, it is possible using GeoJSON:

2 Likes

somehow a single list of latitude and longitude pairs can be drawn in mapviewer.

long ago i made this project where you can use a static exported map and paint something in.

1 Like

i
I tried to do what is described in the post you indicated, i.e. use the GeoJSON property of a MapRoute object and then draw the MapRoute but it doesn’t seem to work

this is the code I used

Dim s As String 


s=" { " _
+" #type#: #FeatureCollection#," _
+" #features#: [" _
+" {" _
+" #type#: #Feature#," _
+" #properties#: {}," _
+" #geometry#: {" _
+" #coordinates#: [" _
+" [" _
+" 43.8973954000000006," _
+" 11.0101534999999995" _
+" ]," _
+" [" _
+" 43.8979954000000206," _
+" 11.0101554999999995" _
+" ]" _
+" ]," _
+" #type#: #LineString#" _
+" }" _
+" }" _
+" ]" _
+" }" 
s=s.ReplaceAll("#",Chr(34)) 


Dim r As New MapRoute
Dim d As Dictionary

MapViewer1.Zoom=18

d=ParseJSON(s)
r.GeoJSON=d

r.TransportType=MapRoute.TransportTypes.Car
MapViewer1.RoutePenSize=10
MapViewer1.DrawRoute(r)



MapViewer1.AddLocation(New WebMapLocation(43.8973954000000006,11.0101534999999995))

MapViewer1.GoToLocation(MapViewer1.LocationAt(MapViewer1.LastLocationIndex))


a FeatureCollection does not work in Xojo.
just add a few waypoints and then look into the .GeoJSON to see the format Xojo currently use.
would be nice if you make a feature request for FeatureCollection to work correct in Xojo.

btw. you can also use a multiline textbox as json input for a test instead of this ugly string

s=" { " _
1 Like