Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navigation Lines #35

Open
danielcooper-hk opened this issue Jun 14, 2024 · 5 comments
Open

Navigation Lines #35

danielcooper-hk opened this issue Jun 14, 2024 · 5 comments

Comments

@danielcooper-hk
Copy link

Hello,

I think LeafletForBlazor can really help my project out and I think I'm being a bit stupid here but cannot work it out.

I am currently using syncfusion maps and they are soooooo slow when you get to more than 200 waypoints on the map.

What I cannot seem to work out is how to create navigation lines between two sets of Co-ordinates in LeafletForBlazor.

I am plotting how goods can move from a warehouse to a seaport, then to the corresponding seaport then to the destination at the other end. There could be a couple of thousand sets of co-ordinates.

Can you point me in the right direction of drawing lines between map points?

Thanks,

Dan.

@ichim
Copy link
Owner

ichim commented Jun 14, 2024

Hello sir,

First of all, I would like to understand what it is about. Basically, there are three ways to draw lines, polylines or lines between two pairs of coordinates:

  1. First, DisplayPolylinesFromArray class provides addMeasure() method with which you can create lines between two pairs of coordinates. This method can display a label (midle of the line - measure line) with a text, for example distance.
  2. Second, DisplayPolylinesFromArray provides add() method with which you create polylines (many pairs of coordinates)
  3. But not least, the DataFromGeoJSON class that will allow you to display lines (but also points and polygons) stored in GeoJSON files.

Can you tell me what kind of lines they are?

From your description it is possible that addMeasure() from on DisplayPolylinesFromArray.

Laurentiu

@danielcooper-hk
Copy link
Author

danielcooper-hk commented Jun 14, 2024 via email

@ichim
Copy link
Owner

ichim commented Jun 15, 2024

Hello sir,

I'm sorry, but I didn't understand. please give me examples (code) of what the coordinate pairs of the lines look like, as you want to draw them.

@danielcooper-hk
Copy link
Author

Apologies Laurantiu, sending the response by email hasn't worked. Let me try again here directly.

The class I store the way points in is driven by the way Syncfusion wants to receive them. It is a double[] [startLat, endLat] and a double[] [startLong, endLong]:

public class MapNavigationLines
{
    public double[] Longitude { get; set; } = [];

    public double[] Latitude { get; set; } = [];

    public String Color { get; set; } = string.Empty;

    public string DashArray { get; set; } = "0";

    public double LineAngle { get; set; } = 0;
}

I use Color to set a different colour depending on the transportation type (i.e. air, road, rail or sea).

I have to transform into this format to use Syncfusion from the way it is stored in the database which is:

public class GeoRoutingLeg
{
    public bool IsRoad { get; set; } = false;

    public bool IsAir { get; set; } = false;

    public bool IsSea { get; set; } = false;

    public bool IsRail { get; set; } = false;

    public List<GeoRoutingWayPoints> WayPoints { get; set; } = [];
}

public class GeoRoutingWayPoints
{
    public double Longitude { get; set; } = 0;

    public double Latitude { get; set; } = 0;
}

Here, the first record in the list is the start point and the end is the endpoint, so the pairs would be [0,1] [1,2] [2,3] etc.

If the waypoints gets over 300 Syncfusion really struggles to draw the map.

Here is the Syncfusion Blazor Map component code also:

<SfMaps @ref="map" Height="100%">
    <MapsLayers>

        <MapsLayer UrlTemplate="https://a.tile.openstreetmap.org/level/tileX/tileY.png" TValue="string">

            <MapsShapeSettings Fill="#F5F1F0">
                <MapsShapeBorder Color="black" Width="0.2"></MapsShapeBorder>
            </MapsShapeSettings>

            <MapsZoomSettings Enable="true" ZoomFactor="4" MaxZoom="40" ShouldZoomInitially="true" MouseWheelZoom="false">
                <MapsZoomToolbarSettings>
                    <MapsZoomToolbarButton ToolbarItems="new List<Syncfusion.Blazor.Maps.ToolbarItem>() { Syncfusion.Blazor.Maps.ToolbarItem.Zoom, Syncfusion.Blazor.Maps.ToolbarItem.ZoomIn, Syncfusion.Blazor.Maps.ToolbarItem.ZoomOut, Syncfusion.Blazor.Maps.ToolbarItem.Pan, Syncfusion.Blazor.Maps.ToolbarItem.Reset }"> </MapsZoomToolbarButton>
                </MapsZoomToolbarSettings>
            </MapsZoomSettings>

            <MapsMarkerSettings>
                <MapsMarker Visible="true" Height="25" Width="25" DataSource="cities" TValue="MapCities">
                    <MapsMarkerTooltipSettings Visible="true" ValuePath="Name"></MapsMarkerTooltipSettings>
                </MapsMarker>
            </MapsMarkerSettings>
                               
            <MapsShapeSettings Autofill="true">
                <MapsNavigationLines>
                    @foreach (MapNavigationLines line in navigationLines)
                    {
                        <MapsNavigationLine Visible="true" Width="2" Color="@line.Color" Latitude="@line.Latitude" Longitude="@line.Longitude" DashArray="@line.DashArray" Angle="@line.LineAngle"></MapsNavigationLine>
                    }
                </MapsNavigationLines>
            </MapsShapeSettings>
        </MapsLayer>
    </MapsLayers>
</SfMaps>

in you can see that Syncfusion wants to receive the Latitude and Longitude in pairs rather than pairs of co-ordinates. The map it creates, and what I want to recreate using your library is:

image

I'm hopeless at Java/Javascript so was really hoping I could replace Syncfusion maps with Leaflet using your library.

The map will display a different route depending on which product the user selects and this part is where Syncfusion gets really slow as the user can wait up to 30 seconds to see the map. They have improved the component but it is still too slow for my purpose.

The only other requirement I have is blocking zooming using the mouse. One of the main users is on a Mac and the Apple Magic Mouse is super sensitive and it can cause chaos on the map if you get the angle of you hand wrong whilst hovering over the map.

Apologies for the previous reply, the email didn't include the attachments I pasted.

Hope this helps to explain my use case. Thanks for your help so far, Dan.

@ichim
Copy link
Owner

ichim commented Jun 15, 2024

For this moment, I would recommend using the data in GeoJSON format:

https://github.com/ichim/LeafletForBlazor-NuGet/tree/main/RTM%20and%20GeoJSON/working%20with%20Files/GeoJSON%20from%20file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants