geoadmin / web-mapviewer

The viewer application for maps and geodata
https://map.geo.admin.ch
Other
63 stars 11 forks source link

Problem with time slide and WebView2 Navigate2() #1082

Open claudiof2023 opened 2 months ago

claudiof2023 commented 2 months ago

Hi,

The Microsoft Edge WebView2 Navigate2() method does not work with the time slide feature of the new map viewer.

This can be tested with a native application with embedded web content, using for example the FormWebView class. The steps below are only meant for a quick illustration of the problem.

Steps:

  1. Step through the following C# code to open a FormWebView: auxView = new FormWebView();

  2. Enable representation of data time stamps (see attachment 2-time_slide.png)

  3. Step through the following C# code to navigate to new coordinates: decimal north = 1250100.0; decimal east = 2645300.0; FormWebView auxView; auxView.Navigate2(east, north);

  4. The Form content does not slide to the new coordinate. It does without time slide.

2-time_slide

pakb commented 2 months ago

what are you doing in the function auxView.Navigate2(east, north);? the webapp should react to changes if they occur in the hash query.

Meaning if you change https://map.geo.admin.ch?center=x,y to https://map.geo.admin.ch?center=a,b it won't update but reload the entire app.

On the other hand if you do https://map.geo.admin.ch/#/map?center=x,y to https://map.geo.admin.ch/#/map?center=a,b it should update the map accordingly (this /#/map is very important, as it tells our Vue Router that you are on the map view, and that the parameters of this view have changed)

claudiof2023 commented 2 months ago

Hi Pascal,

Sure, the code is as follows:

public void Navigate2(decimal east, decimal north) { this.SetCenter(east, north); int pos1 = this.url.IndexOf("&center=");

        if (pos1 > 0)
        {
            int pos2 = this.url.IndexOf("&", pos1 + 8);

            if (pos2 > 0)
            {
                string url2 = this.url.Substring(0, pos1);
                url2 += "&center=" + east.ToString() + "," + north.ToString();
                url2 += this.url.Substring(pos2);
                this.url = url2;
            }
        }

        this.webView.CoreWebView2.Navigate(this.url);
        // this.webView.Source = new UriBuilder(this.url).Uri;

        if (!this.webFormDictonary.ContainsKey(layer))
            this.webFormDictonary[this.layer] = this;
    }

    public void SetCenter(decimal east, decimal north)
    {
        this.current_north = north;
        this.current_east = east;
        this.current_wgs84[0] = (Double) this.current_east;
        this.current_wgs84[1] = (Double) this.current_north;

        Reproject.ReprojectPoints(
            this.current_wgs84,
            new[] { 0d },
            ProjectionInfo.FromEpsgCode(2056),
            ProjectionInfo.FromEpsgCode(4326),
            0,
            1);
    }

I tried to change the source Url directly as you can see in the commented part, but the problem is the same as with the Navigate() method: if the time slide is activated (see snapshot in Issue), the content does not recenter to the new coordinates.

Example of url actually processed by this code: From: "https://map.geo.admin.ch/#/map?&z=12&bgLayer=ch.swisstopo.pixelkarte-farbe&layers=ch.swisstopo.swissimage-product@year=2019;ch.bfs.arealstatistik@year=2018&layers_opacity=1,0.75&lang=de&center=2645300.0002,1249999.9995&crosshair=cross"

To: "https://map.geo.admin.ch/#/map?&z=12&bgLayer=ch.swisstopo.pixelkarte-farbe&layers=ch.swisstopo.swissimage-product@year=2019;ch.bfs.arealstatistik@year=2018&layers_opacity=1,0.75&lang=de&center=2645400.0002,1249999.9995&crosshair=cross"

Best regards, Claudio

pakb commented 2 months ago

To be double sure it's not the issue, you might want to check for the position of either ?center= and &center (in case center is the first parameter, it will have a question mark instead of &)

If that doesn't fix the issue, I don't really know how I could debug this. We typically use standard browsers for our tests (Chrome, Firefox, Edge) and didn't have this issue at all

claudiof2023 commented 2 months ago

Thanks for the hint on the position of center, but it’s handled ok and is not the cause.

Thanks for looking into the problem. I’ll come back to you if I find anything new.

Best regards, Claudio

De : Pascal Barth @.> Envoyé : mercredi, 2 octobre 2024 11:28 À : geoadmin/web-mapviewer @.> Cc : Facchinetti Claudio BFS @.>; Author @.> Objet : Re: [geoadmin/web-mapviewer] Problem with time slide and WebView2 Navigate2() (Issue #1082)

To be double sure it's not the issue, you might want to check for the position of either ?center= and &center (in case center is the first parameter, it will have a question mark instead of &)

If that doesn't fix the issue, I don't really know how I could debug this. We typically use standard browsers for our tests (Chrome, Firefox, Edge) and didn't have this issue at all

— Reply to this email directly, view it on GitHubhttps://github.com/geoadmin/web-mapviewer/issues/1082#issuecomment-2388024183, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BDREVVWMKSWYRJH2ZTVB5YLZZO4A7AVCNFSM6AAAAABPFFZLEWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOBYGAZDIMJYGM. You are receiving this because you authored the thread.Message ID: @.***>