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

Map ui controls double render on blazor web app #365

Open
NIZO0 opened this issue Sep 5, 2024 · 13 comments
Open

Map ui controls double render on blazor web app #365

NIZO0 opened this issue Sep 5, 2024 · 13 comments

Comments

@NIZO0
Copy link

NIZO0 commented Sep 5, 2024

The Map renders correctly the first time. However Navigating to a certain page and then navigating back to the MapPage bugs the UI visually and interactively. Hovering over a marker or trying to grap it won't work.

First Render
Screenshot 2024-09-05 113238

Further Renders
Screenshot 2024-09-05 113255

@valentasm1
Copy link
Collaborator

Any console error?
Any simple repro page?

@NIZO0
Copy link
Author

NIZO0 commented Sep 5, 2024

https://github.com/NIZO0/BlazorGoogleMapsBugRepro

I created a repro project.
Refreshing the page manually solves the problem. I think the map is not being disposed correctly when navigating.

@valentasm1
Copy link
Collaborator

valentasm1 commented Sep 6, 2024

How to reproduce?
Start solution, go to Counter, goto home?
What should happen?
Which browser?
I dont see any console errors

Try put random number for v= maybe it cached since assebly version didnt changed

<script src="_content/BlazorGoogleMaps/js/objectManager.js?v=@typeof(App).Assembly.GetName().Version"></script>

@NIZO0
Copy link
Author

NIZO0 commented Sep 9, 2024

Navigate to the WeatherPage for example then navigate back to the HomePage.
There are no console errors.
The map becomes bugged.
I tested on Microsoft Edge and Google, and got the same result.

image

@valentasm1
Copy link
Collaborator

Honestly i saw arrows just now. You should mentions whats wrong. Buggy isnt clear.
So i wanted to check this solution but it didnt helped. Even more you are on same issue.

#342

I dont know how to help. It looks like some blazor stuff.

@MobicomTobias
Copy link

MobicomTobias commented Sep 9, 2024

@NIZO0 We are seeing exact same solution in our production app..

@valentasm1 please have a second look at @NIZO0 repo as it worked first to replicate the issue via:

  1. Downloading repo
  2. Adding following to appsettings.json:
    "GoogleMapsApiKey": "<apikey>"
  3. Launch application, map loads fine initially
  4. Navigate to the Counter page
  5. Navigate back to Home, issue replicates then

This repo is minimalistic so creds to @NIZO0 for taking the time to make it.

The following image is from our own solution.

image

The following is from the reproduction repo by @NIZO0:

image

@valentasm1
Copy link
Collaborator

Sorry but i dont have ideas. I dont work with blazor, i dont work with google maps, so my knowledge is limited.
Maybe it rerenders map multiple times. Maybe check invocation times. Maybe try pure js map. Maybe try init map from js link.

I understand frustration, but my time is very limited and very a lot of.

@MobicomTobias
Copy link

Regardless, thank you for taking the time to read and reply, we will be looking into the newer gmp-map javascript api that google has given and see about potentially extending it to a library eventually (if time permits).

@valentasm1
Copy link
Collaborator

What difference between div and gpm-map?
Documentation dont state any preference
https://developers.google.com/maps/documentation/javascript/add-google-map

@valentasm1 valentasm1 changed the title Navigating Back to MapPage Bugs the UI Map ui controls double render on blazor web app Sep 10, 2024
@MobicomTobias
Copy link

It seems to inherently work better with server rendered components as the items of the maps element can be declared directly as html elements:
https://developers.google.com/maps/documentation/javascript/add-google-map-wc-tut
Vs. the javascript approach:
https://developers.google.com/maps/documentation/javascript/adding-a-google-map

You can see both choices on the left hand side as "Add a Google Map with a marker using HTML" and "Add a Google Map with a marker using Javascript"

If the gmp version can load maps past initial page load (so when dynamically fed gmp elements), then populating the page with gmp elements is much more like how blazor server side operates, but arguably at a networking cost due to the increase in package sizes required, but for most apps, it will be negligible (sidenote: not sure how well optimized the blazor javascript interop synchronization works, so might actually not be a drawback to define the map in gmp elements).

@valentasm1
Copy link
Collaborator

Created related task. It think gmp-map is out of scope currently.
#367

@valentasm1
Copy link
Collaborator

Did you found solution?

@mrakowRC
Copy link

mrakowRC commented Oct 29, 2024

Im getting this error as well is there any solution? Im using server side rendering as well

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

4 participants