Mapsui: LineString not rendering if Layer with Shapefile datasource is present

Created on 7 Jun 2018  路  5Comments  路  Source: Mapsui/Mapsui

As discussed in #203, this issue addresses the behaviour I noticed.

The .zip-file contains a project (Visual Studio 2017, WPF) which shows that no lines are shown despite the presence of the layer containing the lines. If you comment out Line 63 (the line which adds the _coastLayer to the MapControl), you can toggle the lines on or off.

MapsuiLines.zip

question

Most helpful comment

Your problem is the line generation. First you interchanged latitude and longitude. Than you used ToLonLat() instead of FromLonLat. The result is, that the lines are drawn, but with very, very small values around 0/0.

The correct code to see some lines is
````
static IEnumerable GenerateLines()
{
var list = new List();

        for (int lon = -180; lon <= 180; lon += 5)
        {
            var lineString = new LineString();

            for (int lat = -80; lat <= 80; lat += 5)
            {
                var point = new Point(lon, lat);
                var lonlat = SphericalMercator.FromLonLat(lat, lon);

                lineString.Vertices.Add(lonlat);
            }

            list.Add(lineString);
        }

        return list;
    }

````
If I use this code, I see lines :)

All 5 comments

Your problem is the line generation. First you interchanged latitude and longitude. Than you used ToLonLat() instead of FromLonLat. The result is, that the lines are drawn, but with very, very small values around 0/0.

The correct code to see some lines is
````
static IEnumerable GenerateLines()
{
var list = new List();

        for (int lon = -180; lon <= 180; lon += 5)
        {
            var lineString = new LineString();

            for (int lat = -80; lat <= 80; lat += 5)
            {
                var point = new Point(lon, lat);
                var lonlat = SphericalMercator.FromLonLat(lat, lon);

                lineString.Vertices.Add(lonlat);
            }

            list.Add(lineString);
        }

        return list;
    }

````
If I use this code, I see lines :)

Btw. you didn't saw the lines with shape file, because Mapsui changed the resolution, if you add the ShapeFile. So with ShapeFile zoom on shape, without ShapeFile zoom on tiny grid lines.

Wow. Feeling a bit dump rn. Thanks! That fixed it...

Oh, not dump. I had this often. If you look to long on your own code, you will see anything :)

Great that I could help.

@charlenni Thanks for the solution

@MCMainiac Thanks for the sample project. This makes it go so much faster.

Was this page helpful?
0 / 5 - 0 ratings