- Home
- Forum
- Xamarin.Forms
- Draw a Map Route
Draw a Map Route
Hi,
I recently began using the SfMaps control in Xamarin.Forms and have a need to draw a route on the map. I have a collection of 71 geo points (latitude and longitude) that define the route. I'm assuming I would add these points to a layer and connect them some way with a colored line. Do you have a sample that would show how to do this?
Thanks,
Dean
SIGN IN To post a reply.
5 Replies
MP
Michael Prabhu M
Syncfusion Team
September 27, 2018 12:26 PM UTC
Hi Dean,
Query: Need to draw route map.
Currently, we do not have direct support to draw lines to the specified Geo-Coordinates point. To achieve the same, you can create the corresponding shape file layer comprising of lines connecting the specified Geo-Coordinates point. This created shape file layer can be added as a sub layer (additional layer) to the maps.
We have prepared a simple sample by creating a shape file layer that connects two to three points . You can download the sample from the below link.
Output screenshot:
Regards,
Michael
RD
Rjuken Developments
August 24, 2020 11:02 PM UTC
Hello Syncfusion Team,
I was just wondering how did you create this shape file you put as sublayer based on those geoocordinates, with which tool/software/method ?
I was just wondering how did you create this shape file you put as sublayer based on those geoocordinates, with which tool/software/method ?
Thanks.
SS
Sridevi Sivakumar
Syncfusion Team
August 25, 2020 03:26 PM UTC
Hi Rjuken Developments,
Query: how did you create this shapefile you put as sublayer based on that geocoordinate
We can able to achieve your requirement by using the SfMap Geo point collection. We can provide input as the Geo point collection in sample to draw a shape. We can add more number of shapes using Sublayer support of Maps.
Query: how did you create this shapefile you put as sublayer based on that geocoordinate
We can able to achieve your requirement by using the SfMap Geo point collection. We can provide input as the Geo point collection in sample to draw a shape. We can add more number of shapes using Sublayer support of Maps.
Code snippet:
|
<maps:ShapeFileLayer.Points>
<Point>
<Point.X>39.6737</Point.X>
<Point.Y>-100.5</Point.Y>
</Point>
<Point>
<Point.X>61.35</Point.X>
<Point.Y>18.131</Point.Y>
</Point>
<Point>
<Point.X>-32.259</Point.X>
<Point.Y>145.4214</Point.Y>
</Point>
</maps:ShapeFileLayer.Points> |
For more information,
https://help.syncfusion.com/xamarin/maps/shapetype
Regards,
Sridevi S.
Regards,
Sridevi S.
RD
Rjuken Developments
August 28, 2020 05:16 PM UTC
Hello Syncfusion Team,
As I don't use ImageryLayer, could I achieve the same as your sample, cause it throws me a xaml parser exception on "ShapeFilerLayer.Points" ?
Thanks.
I see you use ImageryLayer in the sample you provided. From the docs, I see that I have to use a .shp file to add MapPoints as you provided to add it as sublayer to a ShapeFileLayer, am I right ?
As I don't use ImageryLayer, could I achieve the same as your sample, cause it throws me a xaml parser exception on "ShapeFilerLayer.Points" ?
Thanks.
SS
Sridevi Sivakumar
Syncfusion Team
August 31, 2020 11:32 AM UTC
Hi Rjuken Developments,
Query: Use a .shp file to add MapPoints as you provided to add it as sublayer to a ShapeFileLayer, am I right?
Yes. We have used the sub-layer as ShapeFileLayer itself we have provided points.
As I don't use ImageryLayer, could I achieve the same as your sample?
Yes. It is possible by adding the main layer as ShapeFileLayer instead of ImageryLayer as per in below
Sample link: https://www.syncfusion.com/downloads/support/forum/140062/ze/MapSample-258182118
Query: Use a .shp file to add MapPoints as you provided to add it as sublayer to a ShapeFileLayer, am I right?
Yes. We have used the sub-layer as ShapeFileLayer itself we have provided points.
As I don't use ImageryLayer, could I achieve the same as your sample?
Yes. It is possible by adding the main layer as ShapeFileLayer instead of ImageryLayer as per in below
Sample link: https://www.syncfusion.com/downloads/support/forum/140062/ze/MapSample-258182118
Code snippet:
|
<maps:SfMaps x:Name="Maps" >
<maps:SfMaps.Layers>
<maps:ShapeFileLayer Uri="world1.shp" x:Name="layer">
<maps:ShapeFileLayer.Sublayers>
<maps:ShapeFileLayer x:Name="subLayer" ShapeType="Polyline">
<maps:ShapeFileLayer.Points>
...
</maps:ShapeFileLayer.Points>
...
</maps:ShapeFileLayer>
</maps:ShapeFileLayer.Sublayers>
</maps:ShapeFileLayer>
</maps:SfMaps.Layers>
</maps:SfMaps> |
Screenshot:
If your requirement is to have only ShapeFileLayer to have a both Uri as well as pointers instead of having main and sub-layer then, currently it is supported to add points only for sub-layer.
Regards,
Sridevi S
Regards,
Sridevi S
SIGN IN To post a reply.
- 5 Replies
- 4 Participants
-
DM Dean Martin
- Sep 26, 2018 04:11 PM UTC
- Aug 31, 2020 11:32 AM UTC