How can I draw a straight line between a marker and a location?
- Add shape and marker layers to the Map configuration.
- Attach a handler to the reset event of the Map.
- Create a method that will draw a line between a marker and a specified position.
- Inside the method, retrieve the from and to coordinates for the line by using the locationToView method.
- Get a reference to the shape layer so you can draw on its surface.
- Draw the line by using the Path element.
The following example demonstrates how to draw a straight line between a marker and a location.