# MapViewer and DrawRoute

**URL:** <https://forum.xojo.com/t/mapviewer-and-drawroute/88518>\
**Category:** General\
**Created:** [June 29, 2026, 6:31pm UTC](https://forum.xojo.com/t/mapviewer-and-drawroute/88518 "2026-06-29T18:31:50Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![jury\_buono1](https://forum.xojo.com/user_avatar/forum.xojo.com/jury_buono1/32/17255_2.png) [@jury\_buono1](https://forum.xojo.com/u/jury_buono1)\
**Post date:** [June 29, 2026, 6:31pm UTC](https://forum.xojo.com/t/mapviewer-and-drawroute/88518/1 "2026-06-29T18:31:50Z")

</div>

Anyone know has an example code to draw a route on WebMapViever ?  
The example project inside xojo shows add mapLocation only and not draw route  
The documentation don’t expalin nothing abaut it  
Ai generates bad code that refer to inexistent methods and proprierties  
Does anyone uses mapViever ?

---

<div class="post-metadata">

**Author:** ![Jared\_Feder](https://forum.xojo.com/user_avatar/forum.xojo.com/jared_feder/32/3036_2.png) [@Jared\_Feder](https://forum.xojo.com/u/Jared_Feder)\
**Post date:** [June 29, 2026, 8:44pm UTC](https://forum.xojo.com/t/mapviewer-and-drawroute/88518/3 "2026-06-29T20:44:26Z")

</div>

It looks like you use the Route method which returns a MapRoute object and call DrawRoute and pass in that MapRoute object.

> **[WebMapViewer — Xojo documentation](https://documentation.xojo.com/api/user_interface/web/webmapviewer.html#webmapviewer-route)**
>
> WebMapViewer.AcceptPictureDrop

---

<div class="post-metadata">

**Author:** ![jury\_buono1](https://forum.xojo.com/user_avatar/forum.xojo.com/jury_buono1/32/17255_2.png) [@jury\_buono1](https://forum.xojo.com/u/jury_buono1)\
**Post date:** [June 29, 2026, 9:50pm UTC](https://forum.xojo.com/t/mapviewer-and-drawroute/88518/4 "2026-06-29T21:50:43Z")

</div>

sorry but in documentation there is not examples to use Route/MapRoute or DrawRoute  
i have try this code : (im using mapLibre)

```auto
MapViewer1.RemoveAllLocations

dim p1 as New WebMapLocation(43.7636, 11.2562)
dim p2 as New WebMapLocation(43.7633, 11.2560)    
dim p3 as New WebMapLocation(43.7629, 11.2558)       

p1.Visible=True
p2.Visible=true
p3.Visible=True

MapViewer1.AddLocation(p1)
MapViewer1.AddLocation(p2)
MapViewer1.AddLocation(p3)
MapViewer1.GoToLocation(p1,True)
MapViewer1.Zoom = 18

dim r as new MapRoute
r=MapViewer1.Route(MapRoute.TransportTypes.Car)
MapViewer1.RoutePenSize=3
MapViewer1.RouteDrawingColor=Color.Red

MapViewer1.DrawRoute(r)

```

but the result is this error

 ![image](https://forum.xojo.com/uploads/default/original/3X/c/1/c15ea2027bbbd9021781233273cd7af01a38bd91.png)

 ![image](https://forum.xojo.com/uploads/default/original/3X/3/9/39045b5466b5fab83a413a5348980aca0cbfcb22.png)

---

<div class="post-metadata">

**Author:** ![Jared\_Feder](https://forum.xojo.com/user_avatar/forum.xojo.com/jared_feder/32/3036_2.png) [@Jared\_Feder](https://forum.xojo.com/u/Jared_Feder)\
**Post date:** [June 29, 2026, 10:15pm UTC](https://forum.xojo.com/t/mapviewer-and-drawroute/88518/5 "2026-06-29T22:15:52Z")

</div>

It looks like you’re doing it right, but getting a security error.

ERROR\_WINHTTP\_SECURE\_FAILURE (12175)

Someone with more web knowledge will need to help from here.

---

<div class="post-metadata">

**Author:** ![Tim\_Parnell](https://forum.xojo.com/user_avatar/forum.xojo.com/tim_parnell/32/161_2.png) [@Tim\_Parnell](https://forum.xojo.com/u/Tim_Parnell)\
**Post date:** [June 29, 2026, 10:56pm UTC](https://forum.xojo.com/t/mapviewer-and-drawroute/88518/6 "2026-06-29T22:56:30Z")

</div>

Um, @Ricardo_Cruz should getting a Route be making a HTTP request?

---

<div class="post-metadata">

**Author:** ![Ricardo\_Cruz](https://forum.xojo.com/user_avatar/forum.xojo.com/ricardo_cruz/32/7852_2.png) [@Ricardo\_Cruz](https://forum.xojo.com/u/Ricardo_Cruz)\
**Post date:** [June 30, 2026, 7:39am UTC](https://forum.xojo.com/t/mapviewer-and-drawroute/88518/7 "2026-06-30T07:39:35Z")

</div>

Yes, if you use the `WebMapViewer.DrawRoute(transportType As MapRoute.TransportTypes = MapRoute.TransportTypes.Car)` method signature, or the `WebMapViewer.Route` method, it needs to connect to a web service for getting routes between two or more waypoints. Same as WebMapLocation, it also needs to make HTTP requests for its `LookupAddress`.

If you already have a MapRoute (i.e. you’re caching the route in DB), then `WebMapViewer.DrawRoute(route As MapRoute)` won’t make any HTTP request.

At the moment, the provider host for the routing service cannot be configured, but it would be possible, same as we do with `WebMapLocation.LookupProviderURL`, where you configure it to point to a [Nominatim](https://nominatim.org) service.

For routing, the required service is [Project OSRM](https://project-osrm.org). Xojo uses a public one from OpenStreetMap at the moment. At the moment, if you can host the OSRM service and build the MapRoute properties on your own, you should be able to just call DrawRoute without relying on third party endpoints.

For the tiles service, which also uses OpenStreetMap by default, it’s possible to configure the `WebMapViewer.StyleURL` and host a Tile Service, like the [Martin Vector Tiles Server](https://martin.maplibre.org).

---

<div class="post-metadata">

**Author:** ![Ricardo\_Cruz](https://forum.xojo.com/user_avatar/forum.xojo.com/ricardo_cruz/32/7852_2.png) [@Ricardo\_Cruz](https://forum.xojo.com/u/Ricardo_Cruz)\
**Post date:** [June 30, 2026, 9:12am UTC](https://forum.xojo.com/t/mapviewer-and-drawroute/88518/8 "2026-06-30T09:12:51Z")

</div>

Not sure why it’s throwing a security issue, it connects fine from macOS, but I’ve found an unrelated issue while testing this, when calling DrawRoute outside of the Opening event.

[Issue #81563](https://tracker.xojo.com/xojoinc/xojo/-/issues/81563)

A workaround is possible, I’ll post a comment there with the instructions.

---

<div class="post-metadata">

**Author:** ![James\_Mullins](https://forum.xojo.com/user_avatar/forum.xojo.com/james_mullins/32/287_2.png) [@James\_Mullins](https://forum.xojo.com/u/James_Mullins)\
**Post date:** [July 2, 2026, 12:24pm UTC](https://forum.xojo.com/t/mapviewer-and-drawroute/88518/9 "2026-07-02T12:24:44Z")

</div>

Hi all. While we’re on topic, does anyone have a navigation option? Ie. Turn by turn directions? Obviously need realtime gps input.

---

<div class="post-metadata">

**Author:** ![Ricardo\_Cruz](https://forum.xojo.com/user_avatar/forum.xojo.com/ricardo_cruz/32/7852_2.png) [@Ricardo\_Cruz](https://forum.xojo.com/u/Ricardo_Cruz)\
**Post date:** [July 2, 2026, 2:18pm UTC](https://forum.xojo.com/t/mapviewer-and-drawroute/88518/10 "2026-07-02T14:18:27Z")

</div>

Inside MapRoute, there is a GeoJSON ([Wikipedia](https://en.wikipedia.org/wiki/GeoJSON)) property that we use for drawing the route on the map. There you’ll find a list of waypoints that (with some maths) you should be able to use for turn by turn directions, I guess. GeoJSON format is broad, we’re just using LineString so you can ignore everything else from the specifications. For example:

 ![GeoJSON](https://forum.xojo.com/uploads/default/original/3X/c/6/c6d9fb7e114c5bea2d7540d28c5644cd04058481.png)

[WebMapLocation.DistanceTo](https://documentation.xojo.com/api/web/webmaplocation.html#webmaplocation-distanceto) can also help finding the nearest waypoint.

For generating a MapRoute between two or more locations, add some to a WebMapViewer with [AddLocation](https://documentation.xojo.com/api/user_interface/web/webmapviewer.html#webmapviewer-addlocation) and then call the [Route](https://documentation.xojo.com/api/user_interface/web/webmapviewer.html#webmapviewer-route) method.

Please make sure to credit OpenStreetMap folks for using their data 🙂

---

<div class="post-metadata">

**Author:** ![jury\_buono1](https://forum.xojo.com/user_avatar/forum.xojo.com/jury_buono1/32/17255_2.png) [@jury\_buono1](https://forum.xojo.com/u/jury_buono1)\
**Post date:** [October 7, 2026, 4:50pm UTC](https://forum.xojo.com/t/mapviewer-and-drawroute/88518/11 "2026-10-07T16:50:31Z")

</div>

> [@Ricardo\_Cruz](#):
>
> For generating a MapRoute between two or more locations, add some to a WebMapViewer with [AddLocation](https://documentation.xojo.com/api/user_interface/web/webmapviewer.html#webmapviewer-addlocation) and then call the [Route](https://documentation.xojo.com/api/user_interface/web/webmapviewer.html#webmapviewer-route) method.

The one you indicated isn’t working; could you paste a code example (using MapLibre) that adds three `webMapcLocation` points and then draws a road connecting them? Thanks.

---

<div class="post-metadata">

**Author:** ![Ricardo\_Cruz](https://forum.xojo.com/user_avatar/forum.xojo.com/ricardo_cruz/32/7852_2.png) [@Ricardo\_Cruz](https://forum.xojo.com/u/Ricardo_Cruz)\
**Post date:** [October 7, 2026, 5:06pm UTC](https://forum.xojo.com/t/mapviewer-and-drawroute/88518/12 "2026-10-07T17:06:05Z")

</div>

I’ll be able to post one tomorrow morning
