Articles in this section
Category / Section

How to Draw a Line (route) Between Two Terminals in the .NET MAUI Maps (SfMaps)

3 mins read

The Syncfusion® .NET MAUI Maps control allows you to draw a line (route) between two terminals using specific latitude and longitude coordinates. Follow the steps below to implement this functionality.

Initialize the SfMaps control and configure the map layer by setting the ShapesSource property.

XAML:

<map:SfMaps>
   <map:SfMaps.Layer>
       <map:MapShapeLayer ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json">
       </map:MapShapeLayer>
   </map:SfMaps.Layer>
</map:SfMaps>

Use the Latitude and Longitude properties of MapLatLng class with the From and To property of Mapline class as per the below demonstration to draw a line between two terminals.

XAML:

<map:SfMaps>
   <map:SfMaps.Layer>
       <map:MapShapeLayer ShapesSource="https://cdn.syncfusion.com/maps/map-data/world-map.json">
           <map:MapShapeLayer.Sublayers>
               <map:MapLineLayer>
                   <map:MapLineLayer.Lines>
                       <map:MapLine>
                           <map:MapLine.From>
                               <map:MapLatLng Latitude="28.7041" Longitude="77.1025" />
                           </map:MapLine.From>
                           <map:MapLine.To>
                               <map:MapLatLng Latitude="-34.603722" Longitude="-58.381592" />
                           </map:MapLine.To>
                       </map:MapLine>
                   </map:MapLineLayer.Lines>
               </map:MapLineLayer>
           </map:MapShapeLayer.Sublayers>
       </map:MapShapeLayer>
   </map:SfMaps.Layer>
</map:SfMaps>

Download the complete sample from GitHub.

Output:

LineBetweenTerminals.png

Conclusion:

I hope you enjoyed learning how to draw a line (route) between two terminals in the .NET MAUI Maps (SfMaps).

You can refer to our .NET MAUI Maps feature tour page to learn about its other groundbreaking feature representations. Explore our .NET MAUI Maps documentation to understand how to present and manipulate data.

For current customers, check out our .NET MAUI components from the License and Downloads page. If you are new to Syncfusion®, try our 30-day free trial to check out our .NET MAUI Maps and other .NET MAUI components.

Please let us know in the comments section if you have any queries or require clarification. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied